You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar question and didn't find it.
I searched the Typer documentation, with the integrated search.
I already searched in Google "How to X in Typer" and didn't find any information.
I already read and followed all the tutorials in the docs and didn't find an answer.
I already checked if it is not related to Typer but to Click.
Commit to Help
I commit to help with one of those options 👆
Example Code
importtyperfromtyping_extensionsimportAnnotated@app.command()defhello(
name: Annotated[str, typer.Argument()],
formal: Annotated[bool, typer.Option("--formal", "-f")],
):
ifformal:
print(f"Hello {name} in a more formal way")
else:
print(f"Hello {name}")
Description
In function parameter formal if I remove the positional arguments in typer.Option(), then running python main.py --help will show --no-formal as a viable option name, but if I add the positional arguments back, then I lose the option name --no-formal. How can I add custom option names while also retaining the option name --no-formal?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
In function parameter
formal
if I remove the positional arguments intyper.Option()
, then runningpython main.py --help
will show--no-formal
as a viable option name, but if I add the positional arguments back, then I lose the option name--no-formal
. How can I add custom option names while also retaining the option name--no-formal
?Operating System
Windows
Operating System Details
No response
Typer Version
0.15.2
Python Version
Python 3.10.15
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions