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
fromtypingimportAnnotatedimporttyperfromtyper.rich_utilsimportMARKUP_MODE_MARKDOWNapp=typer.Typer(rich_markup_mode=MARKUP_MODE_MARKDOWN)
@app.command()defsub(
user: Annotated[
str,
typer.Option(
"-u",
"--user",
help="The name of the user.",
envvar="USERNAME",
),
] ="exampleuser",
):
print(user)
if__name__=="__main__":
app()
Description
When running the above code with --help:
desired output (also the output with rich_markup_mode="rich"):
--user -u STR Name of the User [env var: USERNAME] [default: exampleuser]
actual output:
--user -u STR Name of the User
[env var: USERNAME]
[default: exampleuser]
(The env var and default values are below the help text. I dont know if this markdown formatting keeps the alignment correct.)
The smallest monkey patch I could find to fix it was in rich_utils.py line 283 by forcing
markup_mode="rich" in the call to _make_rich_text(). This is in _get_parameter_help().
This forces the help text to be a Text instead of a Markdown Renderable.
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.
-
First Check
Commit to Help
Example Code
Description
When running the above code with --help:
desired output (also the output with rich_markup_mode="rich"):
actual output:
(The env var and default values are below the help text. I dont know if this markdown formatting keeps the alignment correct.)
The smallest monkey patch I could find to fix it was in rich_utils.py line 283 by forcing
markup_mode="rich" in the call to _make_rich_text(). This is in _get_parameter_help().
This forces the help text to be a Text instead of a Markdown Renderable.
Thanks for Typer!
jh
Operating System
Linux
Operating System Details
No response
Typer Version
0.19.2
Python Version
3.12.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions