Skip to content
Myr

:memo: Update docs with references to --install-completion

Before adoption: this commit came in with the history the project adopted, so no landing records it.

and use subcommand everywhere instead of sub-command for consistency with Click

authored by Sebastián Ramírez · committed by Sebastián Ramírez · parent f192d9d · Browse files · 4 files+54 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+54 added−23 removed

  • other:+54 added−23 removed

4 files+54 added−23 removed

modified:docs/tutorial/index.md+20 added-4 removed
modified:docs/features.md+6 added-3 removed
modified:docs/index.md+14 added-8 removed
32 unmodified lines
33* **Intuitive to write**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.34* **Easy to use**: It's easy to use for the final users. Automatic help commands, and (optional) automatic completion for all shells.35* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.36* **Start simple**: The simplest example adds only 2 lines of code to your app: **1 import, 1 function call**.37* **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups sub-commands, with options and arguments.37* **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups subcommands, with options and arguments.3839## Requirements4041Python 3.6+
51 unmodified lines
9394Usage: main.py [OPTIONS] NAME9596Options:97 --install-completion Install completion for the current shell.98 --show-completion Show completion for the current shell, to copy it or customize the installation.97 --help Show this message and exit.99 --help Show this message and exit.100101// You get a ✨ auto completion ✨ for free, installed with --install-completion102103// Now pass the NAME argument104$ python main.py Camila105106Hello Camila
8 unmodified lines
115This was the simplest example possible.116117Now let's see one a bit more complex.118115### An example with two sub-commands119### An example with two subcommands120121Modify the file `main.py`.122119Create a `typer.Typer()` app, and create two sub-commands with their parameters.123Create a `typer.Typer()` app, and create two subcommands with their parameters.124125```Python hl_lines="3 6 11 20"126import typer127
20 unmodified lines
148And that will:149150* Explicitly create a `typer.Typer` app.151 * The previous `typer.run` actually creates one implicitly for you.148* Add two sub-commands with `@app.command()`.152* Add two subcommands with `@app.command()`.153* Execute the `app()` itself, as if it was a function (instead of `typer.run`).154155### Run the upgraded example156
5 unmodified lines
162163Usage: main.py [OPTIONS] COMMAND [ARGS]...164165Options:166 --install-completion Install completion for the current shell.167 --show-completion Show completion for the current shell, to copy it or customize the installation.162 --help Show this message and exit.168 --help Show this message and exit.169170Commands:171 goodbye172 hello173168// You have 2 sub-commands (the 2 functions): goodbye and hello174// You have 2 subcommands (the 2 functions): goodbye and hello175176// Now get the --help for hello177178$ python main.py hello --help
57 unmodified lines
236```Python237force: bool238```239234And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of sub-commands**, add metadata, extra **validation**, etc.240And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of subcommands**, add metadata, extra **validation**, etc.241242**You get**: great editor support, including **completion** and **type checks** everywhere.243244**Your users get**: automatic **`--help`**, (optional) **autocompletion** in their terminal (Bash, Zsh, Fish, PowerShell).
30 unmodified lines
modified:README.md+14 added-8 removed
32 unmodified lines
33* **Intuitive to write**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.34* **Easy to use**: It's easy to use for the final users. Automatic help commands, and (optional) automatic completion for all shells.35* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.36* **Start simple**: The simplest example adds only 2 lines of code to your app: **1 import, 1 function call**.37* **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups sub-commands, with options and arguments.37* **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups subcommands, with options and arguments.3839## Requirements4041Python 3.6+
51 unmodified lines
9394Usage: main.py [OPTIONS] NAME9596Options:97 --install-completion Install completion for the current shell.98 --show-completion Show completion for the current shell, to copy it or customize the installation.97 --help Show this message and exit.99 --help Show this message and exit.100101// You get a ✨ auto completion ✨ for free, installed with --install-completion102103// Now pass the NAME argument104$ python main.py Camila105106Hello Camila
8 unmodified lines
115This was the simplest example possible.116117Now let's see one a bit more complex.118115### An example with two sub-commands119### An example with two subcommands120121Modify the file `main.py`.122119Create a `typer.Typer()` app, and create two sub-commands with their parameters.123Create a `typer.Typer()` app, and create two subcommands with their parameters.124125```Python hl_lines="3 6 11 20"126import typer127
20 unmodified lines
148And that will:149150* Explicitly create a `typer.Typer` app.151 * The previous `typer.run` actually creates one implicitly for you.148* Add two sub-commands with `@app.command()`.152* Add two subcommands with `@app.command()`.153* Execute the `app()` itself, as if it was a function (instead of `typer.run`).154155### Run the upgraded example156
5 unmodified lines
162163Usage: main.py [OPTIONS] COMMAND [ARGS]...164165Options:166 --install-completion Install completion for the current shell.167 --show-completion Show completion for the current shell, to copy it or customize the installation.162 --help Show this message and exit.168 --help Show this message and exit.169170Commands:171 goodbye172 hello173168// You have 2 sub-commands (the 2 functions): goodbye and hello174// You have 2 subcommands (the 2 functions): goodbye and hello175176// Now get the --help for hello177178$ python main.py hello --help
57 unmodified lines
236```Python237force: bool238```239234And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of sub-commands**, add metadata, extra **validation**, etc.240And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of subcommands**, add metadata, extra **validation**, etc.241242**You get**: great editor support, including **completion** and **type checks** everywhere.243244**Your users get**: automatic **`--help`**, (optional) **autocompletion** in their terminal (Bash, Zsh, Fish, PowerShell).
30 unmodified lines