diff --git a/src/gallia/command/uds.py b/src/gallia/command/uds.py index 17cd78b61..0a7f881ee 100644 --- a/src/gallia/command/uds.py +++ b/src/gallia/command/uds.py @@ -34,7 +34,9 @@ class UDSScannerConfig(ScannerConfig, cli_group="uds", config_section="gallia.pr 2, description="Timeout value to wait for a response from the ECU", metavar="SECONDS" ) max_retries: int = Field( - 3, description="Number of maximum retries while sending UDS requests. If supported by the transport, this will trigger reconnects if required.", metavar="INT" + 3, + description="Number of maximum retries while sending UDS requests. If supported by the transport, this will trigger reconnects if required.", + metavar="INT", ) ping: bool = Field(True, description="Enable/Disable initial TesterPresent request") tester_present_interval: float = Field( diff --git a/src/gallia/commands/scan/uds/identifiers.py b/src/gallia/commands/scan/uds/identifiers.py index 7af787897..1d061d5f7 100644 --- a/src/gallia/commands/scan/uds/identifiers.py +++ b/src/gallia/commands/scan/uds/identifiers.py @@ -30,7 +30,7 @@ class ScanIdentifiersConfig(UDSScannerConfig): ) service: EnumArg[UDSIsoServices] = Field( UDSIsoServices.ReadDataByIdentifier, - description="\n Service (ID) to scan; defaults to ReadDataByIdentifier;\n currently supported:\n 0x27 Security Access;\n 0x22 Read Data By Identifier;\n 0x2e Write Data By Identifier;\n 0x31 Routine Control;\n ", + description="Service (ID) to scan; defaults to ReadDataByIdentifier;\ncurrently supported:\n0x27 Security Access;\n0x22 Read Data By Identifier;\n0x2e Write Data By Identifier;\n0x31 Routine Control;\n", ) check_session: int | None = Field( None, @@ -40,7 +40,7 @@ class ScanIdentifiersConfig(UDSScannerConfig): skip: Ranges2D = Field( {}, metavar="SESSION_ID:ID", - description="\n The data identifiers to be skipped per session.\n A session specific skip is given by :\n where is a comma separated list of single ids or id ranges using a dash.\n Examples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\n Multiple session specific skips are separated by space.\n Only takes affect if --sessions is given.\n ", + description="The data identifiers to be skipped per session.\nA session specific skip is given by :\nwhere is a comma separated list of single ids or id ranges using a dash.\nExamples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\nMultiple session specific skips are separated by space.\nOnly takes affect if --sessions is given.\n", ) skip_not_supported: bool = Field( False, description="Stop scanning in session if service seems to be not available" diff --git a/src/gallia/commands/scan/uds/reset.py b/src/gallia/commands/scan/uds/reset.py index 94e72b8c2..551d07a49 100644 --- a/src/gallia/commands/scan/uds/reset.py +++ b/src/gallia/commands/scan/uds/reset.py @@ -23,7 +23,7 @@ class ResetScannerConfig(UDSScannerConfig): skip: Ranges2D = Field( {}, metavar="SESSION_ID:ID", - description="\n The sub functions to be skipped per session.\n A session specific skip is given by :\n where is a comma separated list of single ids or id ranges using a dash.\n Examples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\n Multiple session specific skips are separated by space.\n Only takes affect if --sessions is given.\n ", + description="The sub functions to be skipped per session.\nA session specific skip is given by :\nwhere is a comma separated list of single ids or id ranges using a dash.\nExamples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\nMultiple session specific skips are separated by space.\nOnly takes affect if --sessions is given.\n", ) skip_check_session: bool = Field( False, description="skip check current session; only takes affect if --sessions is given" diff --git a/src/gallia/commands/scan/uds/services.py b/src/gallia/commands/scan/uds/services.py index a63bd448b..eac7da42e 100644 --- a/src/gallia/commands/scan/uds/services.py +++ b/src/gallia/commands/scan/uds/services.py @@ -34,7 +34,7 @@ class ServicesScannerConfig(UDSScannerConfig): skip: Ranges2D = Field( {}, metavar="SESSION_ID:ID", - description="\n The service IDs to be skipped per session.\n A session specific skip is given by :\n where is a comma separated list of single ids or id ranges using a dash.\n Examples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\n Multiple session specific skips are separated by space.\n Only takes affect if --sessions is given.\n ", + description="\nThe service IDs to be skipped per session.\nA session specific skip is given by :\nwhere is a comma separated list of single ids or id ranges using a dash.\nExamples:\n - 0x01:0xf3\n - 0x10-0x2f\n - 0x01:0xf3,0x10-0x2f\nMultiple session specific skips are separated by space.\nOnly takes affect if --sessions is given.\n", ) diff --git a/vendor/pydantic-argparse/pydantic_argparse/argparse/parser.py b/vendor/pydantic-argparse/pydantic_argparse/argparse/parser.py index c2d21e85b..ec593294e 100644 --- a/vendor/pydantic-argparse/pydantic_argparse/argparse/parser.py +++ b/vendor/pydantic-argparse/pydantic_argparse/argparse/parser.py @@ -80,24 +80,15 @@ def __init__( :param extra_defaults: Defaults coming from external sources, such as environment variables or config files. """ # Initialise Super Class - if sys.version_info < (3, 9): # pragma: <3.9 cover - super().__init__( - prog=prog, - description=description, - epilog=epilog, - add_help=False, # Always disable the automatic help flag. - argument_default=argparse.SUPPRESS, # Allow `pydantic` to handle defaults. - ) - - else: # pragma: >=3.9 cover - super().__init__( - prog=prog, - description=description, - epilog=epilog, - exit_on_error=exit_on_error, - add_help=False, # Always disable the automatic help flag. - argument_default=argparse.SUPPRESS, # Allow `pydantic` to handle defaults. - ) + super().__init__( + prog=prog, + description=description, + epilog=epilog, + exit_on_error=exit_on_error, + add_help=False, # Always disable the automatic help flag. + argument_default=argparse.SUPPRESS, # Allow `pydantic` to handle defaults. + formatter_class=argparse.RawTextHelpFormatter + ) # Set Version, Add Help and Exit on Error Flag self.version = version diff --git a/vendor/pydantic-argparse/pydantic_argparse/parsers/enum.py b/vendor/pydantic-argparse/pydantic_argparse/parsers/enum.py index a1e510d56..44c988b27 100644 --- a/vendor/pydantic-argparse/pydantic_argparse/parsers/enum.py +++ b/vendor/pydantic-argparse/pydantic_argparse/parsers/enum.py @@ -17,6 +17,7 @@ from pydantic_argparse.utils.pydantic import PydanticField from .utils import SupportsAddArgument +from ..utils.field import ArgFieldInfo def should_parse(field: PydanticField) -> bool: @@ -46,8 +47,11 @@ def parse_field( enum_type = cast(Type[enum.Enum], field.info.annotation) # Determine Argument Properties - # TODO: Short metavar - metavar = f"{{{', '.join(f'{e.value}' for e in enum_type)}}}" + metavar = enum_type.__name__ + + if isinstance(field.info, ArgFieldInfo) and field.info.metavar is not None: + metavar = field.info.metavar + action = argparse._StoreAction # Add Enum Field @@ -60,4 +64,4 @@ def parse_field( **field.arg_default(), **field.arg_const(), **field.arg_dest(), - ) + ) \ No newline at end of file diff --git a/vendor/pydantic-argparse/pydantic_argparse/parsers/literal.py b/vendor/pydantic-argparse/pydantic_argparse/parsers/literal.py index c73178b17..671c5402c 100644 --- a/vendor/pydantic-argparse/pydantic_argparse/parsers/literal.py +++ b/vendor/pydantic-argparse/pydantic_argparse/parsers/literal.py @@ -11,16 +11,13 @@ """ import argparse -import sys from pydantic_argparse.utils.pydantic import PydanticField from .utils import SupportsAddArgument +from ..utils.field import ArgFieldInfo -if sys.version_info < (3, 8): # pragma: <3.8 cover - from typing_extensions import Literal, get_args -else: # pragma: >=3.8 cover - from typing import Literal, get_args +from typing import Literal, get_args def should_parse(field: PydanticField) -> bool: @@ -51,6 +48,9 @@ def parse_field( metavar = f"{{{', '.join(str(c) for c in choices)}}}" + if isinstance(field.info, ArgFieldInfo) and field.info.metavar is not None: + metavar = field.info.metavar + action = argparse._StoreAction # Add Literal Field