Skip to content

Suppress the (default: …) display for toggle options. #737

@kzrnm

Description

@kzrnm

Toggle options were introduced in #717, but I think it would be better to disable the (default: …) description for toggle options.

In the example below, it’s unclear to users what (default: False) is referring to.

$ python app.py -h
usage: app.py [-h] [--verbose]

options:
  -h, --help  show this help message and exit
  --verbose   verbose log output (default: False)
class RootCommand(
    BaseSettings,
    cli_parse_args=True,
    cli_implicit_flags='toggle',
):
    verbose: CliToggleFlag[bool] = Field(default=False, description='verbose log output')

    def cli_cmd(self):
        print(self)


def main(args: list[str] | None = None):
    CliApp.run(RootCommand, cli_args=args)


if __name__ == '__main__':
    main()

It’s even more confusing when default=True.

$ python app.py -h
usage: app.py [-h] [--no-verbose]

options:
  -h, --help    show this help message and exit
  --no-verbose  Suppress log output (default: True)
class RootCommand(
    BaseSettings,
    cli_parse_args=True,
    cli_implicit_flags='toggle',
):
    verbose: CliToggleFlag[bool] = Field(default=True, description='Suppress log output')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions