Add custom option names while also retaining the option name for false
#1207
-
First Check
Commit to Help
Example Codeimport typer
from typing_extensions import Annotated
@app.command()
def hello(
name: Annotated[str, typer.Argument()],
formal: Annotated[bool, typer.Option("--formal", "-f")],
):
if formal:
print(f"Hello {name} in a more formal way")
else:
print(f"Hello {name}") DescriptionIn function parameter Operating SystemWindows Operating System DetailsNo response Typer Version0.15.2 Python VersionPython 3.10.15 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
YuriiMotov
Sep 15, 2025
Replies: 1 comment
-
You can specify it after formal: Annotated[bool, typer.Option("--formal\--no-formal", "-f/-F")], Docs: https://typer.tiangolo.com/tutorial/parameter-types/bool/#alternative-names |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuriiMotov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can specify it after
/
:Docs: https://typer.tiangolo.com/tutorial/parameter-types/bool/#alternative-names