* Support custom parameter types
While most CLI parameters are strings, ints, etc, we sometimes need custom
types.
Currently typer has no support for it (See #77), and while there are a few hacks, the
likely solution is to add a 'str' argument and parse it inside the main function.
This PR adds support for custom types in 3 different ways:
- Manually specifying a `click_type`
- Manually specifying a `parse` function
- Using a Callable type annotation (It is very common for types to have a string constructor, like `int("1")`)
* Document how to parse custom objects with Typer.
Typer supports parsing of cutom types with:
- A user provided parser class
- A click custom type parser
* 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
* 📝 Tweak and simplify docs
* ✅ Tweak tests to run scripts and remove pragma: nocover in examples
* 📝 Tweak examples for docs, add types and remove # pragma: nocover
* ♻️ Tweak implementation checking for parser and Click type
---------
Co-authored-by: Paulo Costa <me@paulo.costa.nom.br>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
* ✨ Implement custom handling for callbacks with types
* ✨ Implement type-based handling for completion functions
* ✨ Add examples for custom completion
* 📝 Add docs for custom autocompletion
* ✅ Add tests for autocompletion
* ✨ Document using the context
* ✅ Add tests for using the context
* ✅ Add tests init for context
* 🔧 Update Mypy config
* ✅ Add extra tests for completion
* ✏️ Fix format, typos, and minor texts
* ✨ Update docs for printing, include stdout, stderr, and stdin
* ✏️ Add references to FastAPI, fix typos
* ✏️ Fix typo in Typer CLI
* 📝 Update docs for version
* 📝 Update docs for callbacks
* 📝 Update references to stdout/stderr in autocompletion
* 📝 Add docs for password in CLI option
* 📝 Add docs and tests for Testing
* 📝 Add new sections to docs
* 🎨 Fix formatting
* ✨ Re-implement completion
* ✅ Add tests for re-implemented completion
* 🎨 Move mypy config to file
* 🙈 Update .gitignore
* ➕ Remove click-completion, add support for autodetection with shellingham
* ✅ Fix test for PowerShell
* 🐛 Fix PowerShell permissions/test
* 🎨 Format test
* 🏁 Fix PowerShell script for Windows and PowerShell 5
* 📝 Update docs, internal implementation of completion