In summary, you declare once the types of parameters ( CLI arguments and CLI options) as function parameters. Hello Camila // And with the goodbye command $ python main.py goodbye Camilaīye Camila! // And with -formal $ python main.py goodbye -formal Camila Automatic -formal and -no-formal for the bool option ? // And if you use it with the hello command $ python main.py hello Camila Usage: main.py goodbye NAME Arguments: NAME Options: -formal / -no-formal -help Show this message and exit. And now get the -help for goodbye $ python main.py goodbye -help Usage: main.py hello NAME Arguments: NAME Options: -help Show this message and exit. Commands: goodbye hello // You have 2 subcommands (the 2 functions): goodbye and hello // Now get the -help for hello $ python main.py hello -help show-completion Show completion for the current shell, to copy it or customize the installation.
#USE AUTO TYPER INSTALL#
Options: -install-completion Install completion for the current shell. Check the -help $ python main.py -help An example with two subcommands ¶Ĭreate a typer.Typer() app, and create two subcommands with their parameters. Note: auto-completion works when you create a Python package and run it with -install-completion or when you use Typer CLI. When you create a package you get ✨ auto-completion ✨ for free, installed with -install-completion // Now pass the NAME argument $ python main.py Camila
Usage: main.py NAME Arguments: NAME Options: -install-completion Install completion for the current shell.
#USE AUTO TYPER FOR FREE#
You get a -help for free $ python main.py -help You get a nice error, you are missing NAME Usage: main.py NAME Try "main.py -help" for help. Typer stands on the shoulders of a giant. Grow large: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups of subcommands, with options and arguments.Īnd it's intended to be the FastAPI of CLIs.Start simple: The simplest example adds only 2 lines of code to your app: 1 import, 1 function call.Multiple features from each parameter declaration. Automatic help, and automatic completion for all shells. Easy to use: It's easy to use for the final users.Intuitive to write: Great editor support.Typer is a library for building CLI applications that users will love using and developers will love creating. Password CLI Option and Confirmation PromptĪlternatives, Inspiration and Comparisons