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 tutorial 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
importtyperdefmain(component: Annotated[
str,
typer.Argument(
metavar="COMPONENT.EXT",
help="Component template to use (issue `{rootcmd} ls` cmd to list them).",
),
],
):
"""Generate component files from templates. """passif__name__=="__main__":
typer.run(main)
Description
Some help texts of commands and options need to refer to other subcommands and/or their default values and choices. The argparse library supports interpolations for the main command name (%(prog)s), and arguments of its add_argument() method like %(type)s, %(default)s, %(choices)s etc.
In a potential new feature for Typer these would correspond to the typer.Option() and typer.Argument() args. I would also suggest to use str.format() syntax to expand these variables, like {cmd:30} instead of %-interpolation. Furthermore, a new typer.Option(no_help_interpolation: bool=None) argument would disable this feature in case help messages contain too many such patterns.
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
-
First Check
Commit to Help
Example Code
Description
Some help texts of commands and options need to refer to other subcommands and/or their default values and choices. The
argparse
library supports interpolations for the main command name (%(prog)s
), and arguments of itsadd_argument()
method like%(type)s
,%(default)s
,%(choices)s
etc.In a potential new feature for Typer these would correspond to the
typer.Option()
andtyper.Argument()
args. I would also suggest to usestr.format()
syntax to expand these variables, like{cmd:30}
instead of %-interpolation. Furthermore, a newtyper.Option(no_help_interpolation: bool=None)
argument would disable this feature in case help messages contain too many such patterns.Operating System
Linux
Operating System Details
No response
Typer Version
0.9.0
Python Version
3.10
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions