First Check
Commit to Help
Example Code
import typer
app = typer.Typer()
@app.callback()
def main():
"""Main program help text."""
pass
@app.command()
def foo():
"""foo command help text."""
typer.echo("Executed foo.")
if __name__ == "__main__":
app()
Description
Not sure if this should be considered a bug or enhancement, since this was an undocumented change that could potentially be considered a regression.
- In typer<=0.3.2, when the main application is executed without any commands, it would previously print the help text from the callback and exit with status code 0.
- In typer 0.4.0, this same behavior prints only
Try 'app.py --help' for help. and Error: Missing command. and exits with status code 2.
I'm fine with the status code change—it does seem to me like an improvement that it has an error code. Thank you for this change. (Though it would be nice for this to be documented in the change log.)
However, I think it would be useful to also directly print the help text without requiring users to make another invocation with --help, as was the previous behavior. The git program, for example, will exit with status 1 but also print the help text when used without any commands.
This appears to be only a typer change, and not a click change, as typer 0.4.0 behaves the same with way both click 8.0.1 and click 7.1.2.
typer 0.4.0; click 8.0.1
❯ python -c "import typer; print('typer', typer.__version__); import click; print('click', click.__version__)"
typer 0.4.0
click 8.0.1
❯ python app.py
Usage: app.py [OPTIONS] COMMAND [ARGS]...
Try 'app.py --help' for help.
Error: Missing command.
❯ echo $?
2
typer 0.4.0; click 7.1.2
❯ python -c "import typer; print('typer', typer.__version__); import click; print('click', click.__version__)"
typer 0.4.0
click 7.1.2
❯ python app.py
Usage: app.py [OPTIONS] COMMAND [ARGS]...
Try 'app.py --help' for help.
Error: Missing command.
❯ echo $?
2
typer 0.3.2; click 7.1.2
❯ python -c "import typer; print('typer', typer.__version__); import click; print('click', click.__version__)"
typer 0.3.2
click 7.1.2
❯ python app.py
Usage: app.py [OPTIONS] COMMAND [ARGS]...
Main program help text.
Options:
--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.
Commands:
foo foo command help text.
❯ echo $?
0
Operating System
macOS
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.8.10
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Not sure if this should be considered a bug or enhancement, since this was an undocumented change that could potentially be considered a regression.
Try 'app.py --help' for help.andError: Missing command.and exits with status code 2.I'm fine with the status code change—it does seem to me like an improvement that it has an error code. Thank you for this change. (Though it would be nice for this to be documented in the change log.)
However, I think it would be useful to also directly print the help text without requiring users to make another invocation with
--help, as was the previous behavior. Thegitprogram, for example, will exit with status 1 but also print the help text when used without any commands.This appears to be only a typer change, and not a click change, as typer 0.4.0 behaves the same with way both click 8.0.1 and click 7.1.2.
typer 0.4.0; click 8.0.1
typer 0.4.0; click 7.1.2
typer 0.3.2; click 7.1.2
Operating System
macOS
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.8.10
Additional Context
No response