A CLI tool to build beautiful command-line interfaces with type validation.
from piou import Cli, Option
cli = Cli(description='A CLI tool')
@cli.command(cmd='foo', help='Run foo command')
def foo_main(
bar: int = Option(..., help='Bar positional argument (required)'),
baz: str = Option(..., '-b', '--baz', help='Baz keyword argument (required)'),
foo: str | None = Option(None, '--foo', help='Foo keyword argument'),
):
"""
A longer description on what the function is doing.
"""
pass
if __name__ == '__main__':
cli.run()pip install piouOr with uv:
uv add piouOr with conda:
conda install piou -c conda-forgeBy default, Piou uses Rich for beautiful terminal output. If you prefer plain text output or want to minimize dependencies, you can use the raw formatter:
# Install without Rich formatting (Rich is still installed but not used)
pip install piou[raw]
# Or force raw output via environment variable
PIOU_FORMATTER=raw python your_cli.py --helpFull documentation is available at andarius.github.io/piou.
- FastAPI-like developer experience with type hints
- Custom formatters (Rich-based by default)
- Nested command groups / sub-commands
- Derived options for reusable argument patterns
- Async command support
- Type validation and casting
I could not find a library that provided:
- The same developer experience as FastAPI
- Customization of the interface (to build a CLI similar to Poetry)
- Type validation / casting
Typer is the closest alternative but lacks the possibility to format the output in a custom way using external libraries (like Rich).
Piou provides all these possibilities and lets you define your own Formatter.