Allow to specify a bool option as a key value pair #704
Unanswered
lorenzwalthert
asked this question in
Questions
Replies: 2 comments
-
I tested the following code: @app.command(name="test")
def tes(ver: bool = Option(
False, "--verify", "-v",
help="Verify SSL Certificates"
)):
print("ver is", ver) run and @app.command(name="test")
def tes(ver: bool = Option(
False, "--verify", "-v",
is_flag=True,
help="Verify SSL Certificates"
)):
print("ver is", ver) |
Beta Was this translation helpful? Give feedback.
0 replies
-
But what I want to run is @app.command(name="test")
def tes(ver: bool = Option(
False, "--verify", "-v",
is_flag=False,
help="Verify SSL Certificates"
)):
print("ver is", ver) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
I could not find an easy issue where I could contribute. But I did a one time sponsorship of $ 20.- to make up for that.
Example Code
Then, calling the script:
$ python scratch/typer-key-value.py --is-true=False Error: Option '--is-true' does not take a value
Other ideas such as changing the type annotation to
str
is also hacky.Description
I would like to specify a bool option as a key value pair. The use case for this is that in certains circumstances, it's only possible to specify key value pairs for a command line program. In my case, starting a training job on Sagemaker, the hyper-parameters have to be supplied as key-value pairs. So if I have a boolean hyper-parameter, I must type it as a string and then later convert it, which is a workaround.
Operating System
macOS
Operating System Details
No response
Typer Version
0.9.0
Python Version
3.11.4
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions