Skip to content

Commit

Permalink
Always display booleans with both variants (--x/--no-x)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr committed Oct 14, 2024
1 parent aa7706d commit bc4615b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/gallia/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions src/gallia/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 1 addition & 15 deletions vendor/pydantic-argparse/pydantic_argparse/parsers/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit bc4615b

Please sign in to comment.