Open
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue 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
import typer
def main(
name: str,
option_1: str = typer.Option(
"option_1_default",
),
option_2: str = typer.Option(
...,
),
):
print(f"Hello {name}")
print(option_1)
print(option_2)
if __name__ == "__main__":
typer.run(main)
Description
In order to make the help output less cluttered, it makes sense to hide the [default: None]
for arguments and required options since a value must always be passed (meaning that the default doesn't really have any use).
As an aside, I supposed that the default
is sometimes used as an "example," so maybe it could make sense to add an example
param that could be used for this purpose?
Wanted Solution
Current help output:
❯ pdm run python typer_issue.py --help
Usage: typer_issue.py [OPTIONS] NAME
╭─ Arguments ──────────────────────────────────────────────────╮
│ * name TEXT [default: None] [required] │
╰──────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────╮
│ --option-1 TEXT [default: │
│ option_1_default] │
│ * --option-2 TEXT [default: None] │
│ [required] │
│ --install-completion Install completion for │
│ the current shell. │
│ --show-completion Show completion for the │
│ current shell, to copy │
│ it or customize the │
│ installation. │
│ --help Show this message and │
│ exit. │
╰──────────────────────────────────────────────────────────────╯
Desired help output:
❯ pdm run python typer_issue.py --help
Usage: typer_issue.py [OPTIONS] NAME
╭─ Arguments ──────────────────────────────────────────────────╮
│ * name TEXT [required] │
╰──────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────╮
│ --option-1 TEXT [default: │
│ option_1_default] │
│ * --option-2 TEXT [required] │
│ --install-completion Install completion for │
│ the current shell. │
│ --show-completion Show completion for the │
│ current shell, to copy │
│ it or customize the │
│ installation. │
│ --help Show this message and │
│ exit. │
╰──────────────────────────────────────────────────────────────╯
Wanted Code
# No changes to the way `typer` is used
Alternatives
No response
Operating System
Linux, macOS
Operating System Details
No response
Typer Version
0.6.1
Python Version
Python 3.8.14
Additional Context
Obviously, this is a personal preference. I just feel that it helps to clean up the --help
output a little bit.
Activity