3e37e01979
* 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> |
||
---|---|---|
.. | ||
arguments | ||
commands | ||
multiple-values | ||
options | ||
parameter-types | ||
subcommands | ||
app-dir.md | ||
exceptions.md | ||
first-steps.md | ||
index.md | ||
launch.md | ||
options-autocompletion.md | ||
package.md | ||
printing.md | ||
progressbar.md | ||
prompt.md | ||
terminating.md | ||
testing.md | ||
using-click.md |