option with bool type
See original GitHub issue@click.command()
@click.option('--shout/--no-shout', default=False)
def info(shout):
pass
info()
is ok, but
@click.command()
@click.option('--shout/--no-shout', default=False, type=bool)
def info(shout):
pass
info()
will raise a TypeError: Got secondary option for non boolean flag.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Boolean CLI Options - Typer - tiangolo
We have seen some examples of CLI options with bool , and how Typer creates --something and --no-something automatically. But we can customize...
Read more >angular - Get boolean option values
My issue is when clicked on the dropdown I can't get the boolean value, that is true/false, but only strings "true"/"false" hence my...
Read more >optional::OptionBool - Rust
The OptionBool type, a space-efficient Option replacement ... Maps an OptionBool to an Option<U> by applying the function over the contained bool.
Read more >Booleans - Manual
The bool type only has two values, and is used to express a truth value. It can be either true or false ....
Read more >argparse: boolean option pitfall (beginner - YouTube
today I show how to properly handle boolean options in argparse as well as an easy mistake to avoid!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The
type
argument only supportsbool
and notclick.BOOL
, should this be changed to support both?https://github.com/pallets/click/blob/9cfa961deed93af69ab43b679f0a0308fd518ecc/src/click/core.py#L1780
Same here.
type=click.BOOL
repros this bug, too. Temporarily remove the type and resolved.