Skip to content
Myr

features.md

This file

Path

docs/features.md

93 lines · 4.3 KiB · Markdown

Last changed by

🔧 Update MkDocs to have titles in Markdown files instead of config (#913)Sebastián Ramírezbefore adoption6b264ac

History of this file

Take it

The walk stopped after 200 commits: lines older than cfae1d2 point at it.

🔧 Update MkDocs to have titles in Markdown files instead of config (#913)Sebastián Ramírezbefore adoption6b264ac

lines 1–2why, one step back
1# Features
2

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

lines 3–52why, one step back
3## Design based on **FastAPI**
45<a href="https://fastapi.tiangolo.com" target="_blank"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style="width: 20%;"></a>67**Typer** is <a href="https://fastapi.tiangolo.com" class="external-link" target="_blank">FastAPI</a>'s little sibling.89It follows the same design and ideas. If you know **FastAPI**, you already know **Typer**... more or less.1011## Just Modern Python1213It's all based on standard **Python type** declarations. No new syntax to learn. Just standard modern Python.1415If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI or Typer), check the FastAPI tutorial section: <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">Python types intro</a>.1617You will also see a 20 seconds refresher on the section [Tutorial - User Guide: First Steps](tutorial/first-steps.md){.internal-link target=_blank}.1819## Editor support2021**Typer** was designed to be easy and intuitive to use, to ensure the best development experience. With autocompletion everywhere.2223You will rarely need to come back to the docs.2425Here's how your editor might help you:2627* in <a href="https://code.visualstudio.com/" class="external-link" target="_blank">Visual Studio Code</a>:2829![editor support](img/vscode-completion.png)3031* in <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">PyCharm</a>:3233![editor support](img/pycharm-completion.png)3435You will get completion for everything. That's something no other CLI library provides right now.3637No more guessing what type was that variable, if it could be `None`, etc.3839### Short4041It has sensible **defaults** for everything, with optional configurations everywhere. All the parameters can be fine-tuned to do what you need, customize the help, callbacks per parameter, make them required or not, etc.4243But by default, it all **"just works"**.4445## User friendly CLI apps4647The resulting CLI apps created with **Typer** have the nice features of many "pro" command line programs you probably already love.4849* Automatic help options for the main CLI program and all its subcommands.50* Automatic command and subcommand structure handling (you will see more about subcommands in the Tutorial - User Guide).51* Automatic completion for the CLI app in all operating systems, in all the shells (Bash, Zsh, Fish, PowerShell), so that the final user of your app can just hit <kbd>TAB</kbd> and get the available options or subcommands. *52

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 53why, one step back
53/// note | * Auto completion

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 54why, one step back
54

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 55why, one step back
55Auto completion works when you create a package (installable with `pip`). Or when using the `typer` command.

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 56why, one step back
56

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 57why, one step back
57**Typer** uses `shellingham` to auto-detect the current shell when installing completion. If you don't want to include `shellingham`, install `typer-slim`.

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 58why, one step back
58

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 59why, one step back
59**Typer** will automatically create 2 *CLI options*:

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 60why, one step back
60

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 61–62why, one step back
61* `--install-completion`: Install completion for the current shell.
62* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 63why, one step back
63

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 64why, one step back
64If you didn't add `shellingham` (if you installed `pip install typer-slim`) those *CLI options* take a value with the name of the shell to install completion for, e.g.:

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 65why, one step back
65

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 66–67why, one step back
66* `--install-completion bash`.
67* `--show-completion powershell`.

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 68why, one step back
68

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 69why, one step back
69Then you can tell the user to install completion after installing your CLI program and the rest will just work.

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

line 70why, one step back
70

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 71–79why, one step back
71///
7273/// tip7475**Typer**'s completion is implemented internally, it uses ideas and components from Click and ideas from `click-completion`, but it doesn't use `click-completion` and re-implements some of the relevant parts of Click.7677Then it extends those ideas with features and bug fixes. For example, **Typer** programs also support modern versions of PowerShell (e.g. in Windows 10) among all the other shells.7879///

✨ Improve column help display, ensure commands column width is the same on all panels (#567)Sorin Sbarneabefore adoptioncfae1d2

lines 80–93why, one step back
80
81## The power of Click8283<a href="https://click.palletsprojects.com" class="external-link" target="_blank">Click</a> is one of the most popular tools for building CLIs in Python.8485**Typer** is based on it, so you get all its benefits.8687But you can write simpler code with the benefits of modern Python.8889## Tested9091* 100% <abbr title="The amount of code that is automatically tested">test coverage</abbr>.92* 100% <abbr title="Python type annotations, with this your editor and external tools can give you better support">type annotated</abbr> code base.93* Used in production applications.