2019-12-24 13:31:59 +01:00
## Design based on **FastAPI**
:sparkles: Add docs for testing, password, version, context. Extra tests, include callback and autocompletion PR (#68)
* :sparkles: Implement custom handling for callbacks with types
* :sparkles: Implement type-based handling for completion functions
* :sparkles: Add examples for custom completion
* :memo: Add docs for custom autocompletion
* :white_check_mark: Add tests for autocompletion
* :sparkles: Document using the context
* :white_check_mark: Add tests for using the context
* :white_check_mark: Add tests init for context
* :wrench: Update Mypy config
* :white_check_mark: Add extra tests for completion
* :pencil2: Fix format, typos, and minor texts
* :sparkles: Update docs for printing, include stdout, stderr, and stdin
* :pencil2: Add references to FastAPI, fix typos
* :pencil2: Fix typo in Typer CLI
* :memo: Update docs for version
* :memo: Update docs for callbacks
* :memo: Update references to stdout/stderr in autocompletion
* :memo: Add docs for password in CLI option
* :memo: Add docs and tests for Testing
* :memo: Add new sections to docs
* :art: Fix formatting
2020-03-18 21:17:47 +01:00
< a href = "https://fastapi.tiangolo.com" target = "_blank" > < img src = "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style = "width: 20%;" > < / a >
2020-01-18 19:35:49 +01:00
**Typer** is < a href = "https://fastapi.tiangolo.com" class = "external-link" target = "_blank" > FastAPI< / a > 's little sibling.
2019-12-24 13:31:59 +01:00
:sparkles: Add docs for testing, password, version, context. Extra tests, include callback and autocompletion PR (#68)
* :sparkles: Implement custom handling for callbacks with types
* :sparkles: Implement type-based handling for completion functions
* :sparkles: Add examples for custom completion
* :memo: Add docs for custom autocompletion
* :white_check_mark: Add tests for autocompletion
* :sparkles: Document using the context
* :white_check_mark: Add tests for using the context
* :white_check_mark: Add tests init for context
* :wrench: Update Mypy config
* :white_check_mark: Add extra tests for completion
* :pencil2: Fix format, typos, and minor texts
* :sparkles: Update docs for printing, include stdout, stderr, and stdin
* :pencil2: Add references to FastAPI, fix typos
* :pencil2: Fix typo in Typer CLI
* :memo: Update docs for version
* :memo: Update docs for callbacks
* :memo: Update references to stdout/stderr in autocompletion
* :memo: Add docs for password in CLI option
* :memo: Add docs and tests for Testing
* :memo: Add new sections to docs
* :art: Fix formatting
2020-03-18 21:17:47 +01:00
It follows the same design and ideas. If you know **FastAPI** , you already know **Typer** ... more or less.
2019-12-24 13:31:59 +01:00
## Just Modern Python
It's all based on standard **Python 3.6 type** declarations. No new syntax to learn. Just standard modern Python.
2020-01-18 19:35:49 +01:00
If 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 > .
2019-12-24 13:31:59 +01:00
2020-01-18 19:35:49 +01:00
You will also see a 20 seconds refresher on the section [Tutorial - User Guide: First Steps ](tutorial/first-steps.md ){.internal-link target=_blank}.
2019-12-24 13:31:59 +01:00
## Editor support
**Typer** was designed to be easy and intuitive to use, to ensure the best development experience. With autocompletion everywhere.
You will rarely need to come back to the docs.
Here's how your editor might help you:
2020-01-17 16:27:17 +01:00
* in < a href = "https://code.visualstudio.com/" class = "external-link" target = "_blank" > Visual Studio Code</ a > :
2019-12-24 13:31:59 +01:00
![editor support ](img/vscode-completion.png )
2020-01-17 16:27:17 +01:00
* in < a href = "https://www.jetbrains.com/pycharm/" class = "external-link" target = "_blank" > PyCharm</ a > :
2019-12-24 13:31:59 +01:00
![editor support ](img/pycharm-completion.png )
You will get completion for everything. That's something no other CLI library provides right now.
No more guessing what type was that variable, if it could be `None` , etc.
### Short
It 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.
But by default, it all ** "just works"**.
## User friendly CLI apps
The resulting CLI apps created with **Typer** have the nice features of many "pro" command line programs you probably already love.
2020-03-16 13:21:58 +01:00
* Automatic help options for the main CLI program and all its subcommands.
2019-12-28 14:12:47 +01:00
* Automatic command and subcommand structure handling (you will see more about subcommands in the Tutorial - User Guide).
2020-03-11 17:16:49 +01:00
* 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. *
2019-12-24 13:31:59 +01:00
2020-03-11 17:16:49 +01:00
!!! note "* Auto completion"
2020-03-16 13:21:58 +01:00
Auto completion works when you create a package (installable with `pip` ). Or when using [Typer CLI ](typer-cli.md ){.internal-link target=_blank}.
2019-12-24 13:31:59 +01:00
2020-03-16 13:21:58 +01:00
If you also add `shellingham` as a dependency, **Typer** will use it to auto-detect the current shell when installing completion.
**Typer** will automatically create 2 *CLI options* :
2019-12-28 14:12:47 +01:00
* `--install-completion` : Install completion for the current shell.
2020-03-16 13:21:58 +01:00
* `--show-completion` : Show completion for the current shell, to copy it or customize the installation.
:sparkles: Add docs for testing, password, version, context. Extra tests, include callback and autocompletion PR (#68)
* :sparkles: Implement custom handling for callbacks with types
* :sparkles: Implement type-based handling for completion functions
* :sparkles: Add examples for custom completion
* :memo: Add docs for custom autocompletion
* :white_check_mark: Add tests for autocompletion
* :sparkles: Document using the context
* :white_check_mark: Add tests for using the context
* :white_check_mark: Add tests init for context
* :wrench: Update Mypy config
* :white_check_mark: Add extra tests for completion
* :pencil2: Fix format, typos, and minor texts
* :sparkles: Update docs for printing, include stdout, stderr, and stdin
* :pencil2: Add references to FastAPI, fix typos
* :pencil2: Fix typo in Typer CLI
* :memo: Update docs for version
* :memo: Update docs for callbacks
* :memo: Update references to stdout/stderr in autocompletion
* :memo: Add docs for password in CLI option
* :memo: Add docs and tests for Testing
* :memo: Add new sections to docs
* :art: Fix formatting
2020-03-18 21:17:47 +01:00
If you didn't add `shellingham` those *CLI options* take a value with the name of the shell to install completion for, e.g.:
2020-03-16 13:21:58 +01:00
* `--install-completion bash` .
* `--show-completion powershell` .
Then you can tell the user to install completion after installing your CLI program and the rest will just work.
2019-12-24 13:31:59 +01:00
2020-03-16 13:21:58 +01:00
!!! tip
:sparkles: Add docs for testing, password, version, context. Extra tests, include callback and autocompletion PR (#68)
* :sparkles: Implement custom handling for callbacks with types
* :sparkles: Implement type-based handling for completion functions
* :sparkles: Add examples for custom completion
* :memo: Add docs for custom autocompletion
* :white_check_mark: Add tests for autocompletion
* :sparkles: Document using the context
* :white_check_mark: Add tests for using the context
* :white_check_mark: Add tests init for context
* :wrench: Update Mypy config
* :white_check_mark: Add extra tests for completion
* :pencil2: Fix format, typos, and minor texts
* :sparkles: Update docs for printing, include stdout, stderr, and stdin
* :pencil2: Add references to FastAPI, fix typos
* :pencil2: Fix typo in Typer CLI
* :memo: Update docs for version
* :memo: Update docs for callbacks
* :memo: Update references to stdout/stderr in autocompletion
* :memo: Add docs for password in CLI option
* :memo: Add docs and tests for Testing
* :memo: Add new sections to docs
* :art: Fix formatting
2020-03-18 21:17:47 +01:00
**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.
2019-12-24 13:31:59 +01:00
2020-03-16 13:21:58 +01:00
Then 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.
2020-03-11 17:16:49 +01:00
2019-12-24 13:31:59 +01:00
## The power of Click
2020-01-17 16:27:17 +01:00
< 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.
2019-12-24 13:31:59 +01:00
**Typer** is based on it, so you get all its benefits, plug-ins, robustness, etc.
But you can write simpler code with the benefits of modern Python.
<!--
TODO
### Tested
* 100% < abbr title = "The amount of code that is automatically tested" > test coverage</ abbr > .
* 100% < abbr title = "Python type annotations, with this your editor and external tools can give you better support" > type annotated</ abbr > code base.
* Used in production applications. -->