Skip to content

Application crashs when a invalid option is used #5

Description

@Dominiquini

When I tried:

bangen --version

The application crashs instead of inform me about the invalid option:

Usage: bangen [OPTIONS]
Traceback (most recent call last):
  File "typer/core.py", line 187, in _main
    with self.make_context(prog_name, args, **extra) as ctx:
         ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "click/core.py", line 1216, in make_context
  File "click/core.py", line 1224, in parse_args
  File "click/parser.py", line 305, in parse_args
  File "click/parser.py", line 332, in _process_args_for_options
  File "click/parser.py", line 484, in _process_opts
  File "click/parser.py", line 366, in _match_long_opt
click.exceptions.NoSuchOption: No such option: --version

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "_entry.py", line 2, in <module>
  File "bangen/app.py", line 11, in main
    cli_app()
    ~~~~~~~^^
  File "typer/main.py", line 1152, in __call__
    raise e
  File "typer/main.py", line 1135, in __call__
    return get_command(self)(*args, **kwargs)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "click/core.py", line 1485, in __call__
  File "typer/core.py", line 709, in main
    return _main(
        self,
    ...<6 lines>...
        **extra,
    )
  File "typer/core.py", line 211, in _main
    rich_utils.rich_format_error(e)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "typer/rich_utils.py", line 694, in rich_format_error
    RICH_HELP.format(
    ^^^^^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'format'
[PYI-2358222:ERROR] Failed to execute script '_entry' due to unhandled exception!

Version: 2.2.4

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions