Open kmcminn opened 2 years ago
IMO, the current interface is good. Adding the required
parameter, would negate the first parameter (default value), which would be weird (the default value is ignored if required=True
).
If anything, it should be made clearer in the instructions that to make an Option
or Argument
required, ...
should be the default value.
check this out https://typer.tiangolo.com/tutorial/options/required/
I just came across the same problem. I wanted to add a required Option with Choices (Enum). And i didn't want to set a default value, because i wanted that the user gets an error displayed, if he doesn't specify the option. I didn't want default value to execute silently. Hope it makes some sense.
Great package btw ;)
First Check
Commit to Help
Example Code
Description
Please make typer.Option required arguments conform to a more readable syntax than ellipsis.
From the function param:
username: str = typer.Option(..., help="A Username")
unless you have working knowledge of this library you wouldn't be able to know if:
str
Please consider moving this feature to a kwarg in typer.Option.
Wanted Solution
typer.Option supports a new kwarg: required: bool
Wanted Code
Alternatives
N/A
Operating System
Linux
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.9+
Additional Context
No response