anci is a lightweight python package that automatically converts decorated, type-annotated functions into basic or hierarchical command-line interfaces.
anci can be installed using pip
Or, added to your pyproject.toml using uv
This example demonstrates how to create a simple CLI using only decorators and type annotations:
- @anci.base("ops") - Creates a base command group called ops that initializes a hierarchy.
- @anci.cmd("ops", "add") - Registers subcommand add under ops with flagged arguments.
- usage - Usage info for each command (e.g. ops --help) are extracted from function docstrings.
- anci.Arg - Provides type hints and help text for each parameter.
- anci.main() - Automatically generates the CLI with help text, argument parsing, and command routing.
On the command-line, the anci command-line program can then be called as
Or, if integrated as part of your python CLI package, then
anci currently provides support for various annotated_types, allowing automatic enforcement of range and boundary checks on integers, containers (such as lists, sets, and tuples), and strings.
This example shows how anci uses type annotations to handle complex types and enforce runtime checks:
- x: Arg[list[str], ...] - anci converts a sequence of letters into list of strings.
- y: Arg[Annotated[int, Gt(10)], ...]: anci verifies input integer is greater than 10.
- y: Arg[Annotated[set[float], MaxLen(2)], ...]: anci verifies set only has two elements.
When all arguments satisfy the runtime checks, the command runs without errors:
However, since anci enforces range/length constraints directly from type annotations, the following produce errors:
anci currently supports the following type annotations:
- Base types: int, str, float, bool, bytes, pathlib.Path
- Container types: list[...], List[...], tuple[...], Tuple[...], set[...], Set[...]
- annotated_types (typing.Annotated[...]): Gt, Ge, Lt, Le, Interval, MaxLen, MinLen, Len.
All annotated types, and pathlib.Path, can be directly imported/aliased from anci.typing if desired.
If you want to add your new/custom type annotations to anci, see src/anci/handlers for now or, alternatively, open an issue. Documentation on adding your own custom annotations will be added soon.
.png)


