Skip to content

Trogon not handling bool options #104

@bigbirdcode

Description

@bigbirdcode

I have the following example script:

import click
from trogon import tui


@tui()
@click.command()
@click.option("--my-bool", type=bool)
def cli(my_bool):
    print("Hello from trogon-try!")
    print("my-bool:", my_bool)


if __name__ == "__main__":
    cli()

When I execute it with Trogon then I get the error:

[...]

  File "c:\Users\Peter\Documents\work\trogon_try\.venv\Lib\site-packages\trogon\trogon.py", line 256, in <genexpr>
    f"Running [b cyan]{self.app_name} {' '.join(shlex.quote(s) for s in self.post_run_command)}[/]"
                                                ^^^^^^^^^^^^^^
  File "c:\python312\Lib\shlex.py", line 327, in quote
    if _find_unsafe(s) is None:
       ^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'bool'

As I have checked the details, the attribute post_run_command contains the value as bool and not str.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions