💬 友好地提示你缺少 NAME 参数 Usage: main.py [OPTIONS] NAME Try "main.py --help"forhelp.
Error: Missing argument 'NAME'.
💬 自带 --help python main.py --help
Usage: main.py [OPTIONS] NAME
Arguments: NAME [required]
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.
💬 当你创建一个python包,安装时带上--install-completion参数,则获得了自动补全的功能 💬 现在传入 NAME 参数运行 python main.py Camila
@app.command() defgoodbye(name: str, formal: bool = False): if formal: typer.echo(f"Goodbye Ms. {name}. Have a good day.") else: typer.echo(f"Bye {name}!")
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: goodbye hello
💬 包含两个子命令(即两个函数): goodbye and hello
💬 查看子命令 hello 的帮助
python main.py hello --help
Usage: main.py hello [OPTIONS] NAME
Arguments: NAME [required]
Options: --help Show this message and exit.
💬 然后再看下 goodbye 的
python main.py goodbye --help
Usage: main.py goodbye [OPTIONS] NAME
Arguments: NAME [required]
Options: --formal / --no-formal [default: False] --help Show this message and exit.