transport: move argument parser setup into concrete classes

The argument parser is set up globally for all LinkBase objects in
__init__.py. Since we tend to have only platform independed code in
__init__.py, we should move the argument parser setup into the
specific LinkBase classes.

Related: OS#6210
Change-Id: I22c32aa81ca0588e3314c3ff4546f6e5092c11df
This commit is contained in:
Philipp Maier
2023-10-23 10:44:44 +02:00
committed by laforge
parent 3077343739
commit 8c82378bfd
5 changed files with 41 additions and 20 deletions

View File

@@ -19,6 +19,7 @@
import serial
import time
import os.path
import argparse
from typing import Optional
from pySim.exceptions import NoCardError, ProtocolError
@@ -240,3 +241,11 @@ class SerialSimLink(LinkBase):
def __str__(self) -> str:
return "serial:%s" % (self._sl.name)
@staticmethod
def argparse_add_reader_args(arg_parser: argparse.ArgumentParser):
serial_group = arg_parser.add_argument_group('Serial Reader')
serial_group.add_argument('-d', '--device', metavar='DEV', default='/dev/ttyUSB0',
help='Serial Device for SIM access')
serial_group.add_argument('-b', '--baud', dest='baudrate', type=int, metavar='BAUD', default=9600,
help='Baud rate used for SIM access')