From bc4615bd23cf8b3df83badcaa00890d14b8bdc4d Mon Sep 17 00:00:00 2001 From: fabian Date: Mon, 14 Oct 2024 17:06:13 +0200 Subject: [PATCH] Always display booleans with both variants (--x/--no-x) --- src/gallia/cli.py | 2 +- src/gallia/command/base.py | 6 +++--- .../pydantic_argparse/parsers/boolean.py | 16 +--------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/gallia/cli.py b/src/gallia/cli.py index ce1693a47..1664ca4f9 100644 --- a/src/gallia/cli.py +++ b/src/gallia/cli.py @@ -155,7 +155,7 @@ def __call__( if setup_log: setup_logging( level=get_log_level(config.verbose), - no_volatile_info=config.no_volatile_info, + no_volatile_info=not config.volatile_info, ) sys.exit(get_command(config).entry_point()) diff --git a/src/gallia/command/base.py b/src/gallia/command/base.py index 237839238..b85f761c5 100644 --- a/src/gallia/command/base.py +++ b/src/gallia/command/base.py @@ -114,8 +114,8 @@ class BaseCommandConfig(GalliaBaseModel, argument_group="generic", config_sectio model_config = ConfigDict(arbitrary_types_allowed=True) verbose: int = Field(0, description="increase verbosity on the console", short="v") - no_volatile_info: bool = Field( - False, description="do not overwrite log lines with level info or lower in terminal output" + volatile_info: bool = Field( + True, description="Overwrite log lines with level info or lower in terminal output" ) trace_log: bool = Field(False, description="set the loglevel of the logfile to TRACE") pre_hook: str | None = Field( @@ -452,7 +452,7 @@ def run(self) -> int: class ScannerConfig(AsyncScriptConfig, argument_group="scanner", config_section="gallia.scanner"): dumpcap: bool = Field( - sys.platform == "linux", description="Enable/Disable creating a pcap file" + sys.platform.startswith("linux"), description="Enable/Disable creating a pcap file" ) target: Idempotent[TargetURI] = Field( description="URI that describes the target", metavar="TARGET" diff --git a/vendor/pydantic-argparse/pydantic_argparse/parsers/boolean.py b/vendor/pydantic-argparse/pydantic_argparse/parsers/boolean.py index 1883882ef..4087920f9 100644 --- a/vendor/pydantic-argparse/pydantic_argparse/parsers/boolean.py +++ b/vendor/pydantic-argparse/pydantic_argparse/parsers/boolean.py @@ -46,22 +46,8 @@ def parse_field( Returns: Optional[PydanticValidator]: Possible validator method. """ - # Compute Argument Intrinsics - invalid_extra_default = field.extra_default is not None and field.validated_extra_default is None - - if field.validated_extra_default is not None: - is_inverted = field.validated_extra_default - else: - is_inverted = not field.info.is_required() and bool(field.info.get_default()) - # Determine Argument Properties - action = ( - actions.BooleanOptionalAction - if field.info.is_required() or invalid_extra_default - else argparse._StoreFalseAction - if is_inverted - else argparse._StoreTrueAction - ) + action = actions.BooleanOptionalAction # Add Boolean Field parser.add_argument(