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
importtyperdefhelperText(module: str, sub_cmd: str):
sub_cmd_list= ["archive"]
ifnotsub_cmd:
returnf"The `{command}` command is used to parse {command} data from one format to another."ifsub_cmd=="dry":
returnf"Perform a dry run to validate the {command} data parsing without making any changes."ifsub_cmdinsub_cmd_list:
returnf"Parse the {command} data and upload it to {sub_command} destination."app=typer.Typer(help=helperText("data"))
@app.command("dry", help=helperText("data", "dry"))defcli_parse_data(tenant: str):
data= {}
print(tenant)
print(data)
@app.command("archive", help=helperText("data", "archive"))defcli_archive_data(tenant: str):
data= {}
print(tenant)
print(data)
upload(data)
if__name__=="__main__":
app()
Description
Is there a way to dynamically create a help string to include the name of the command used and sub-command?
The docs show Metavar being accessible but it is only for params. It would be really cool to have this feature for the whole context.
@app.command("archive")defcli_dry():
""" Parse the `<PARENT_COMMAND>` and upload it to `<COMMAND>` destination. """print("Hello World")
output
$app data archive --help
Parse the `data` and upload it to `archive` destination.
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
Is there a way to dynamically create a help string to include the name of the command used and sub-command?
The docs show Metavar being accessible but it is only for params. It would be really cool to have this feature for the whole context.
output
Operating System
Windows
Operating System Details
No response
Typer Version
0.9.4
Python Version
3.11.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions