Declarative CLI argument parser.
Actively maintained. Last release 7 weeks ago, commits in 12 of the last 26 weeks. A safe choice.
pip install cappaCappa
- Full Documentation
- Comparison vs click/typer/argparse/etc
- Annotations Inference Docs
- "invoke" API Docs
- Class Compatibility (dataclasses/pydantic/etc)
Cappa is a declarative command line parsing library, which uses runtime type inspection to infer (default) CLI argument behavior, and provide automatic help text generation and dynamic completion generation.
It supports two different modes of execution:
-
parse: Argparse-like parsing of the arguments into an output structure -
invoke: Click-like calling of functions based on the selected subcommand
It also provides a dependency injection system for providing non-argument resources to the invoked commands.
And, a number of different styles of CLI declaration (which can be mixed and matched within a given CLI):
- Classes: The fields of the class correspond to CLI arguments/subcommands
- Functions: The arguments of the function correspond to CLI arguments
- Methods: The class fields correspond to CLI arguments, and the methods correspond to subcommands
- Imperative Construction: The CLI structure can be manually/imperitavely constructed, rather than being inferred from the input structure