Skip to content

Andarius/piou

Repository files navigation

Piou logo

Piou

Python versions Latest PyPI version CI Latest conda-forge version

A CLI tool to build beautiful command-line interfaces with type validation.

Quick Example

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()

example

Installation

pip install piou

Or with uv:

uv add piou

Or with conda:

conda install piou -c conda-forge

Without Rich (Raw Formatter)

By 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 --help

Documentation

Full documentation is available at andarius.github.io/piou.

Features

  • 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

Why Piou?

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.

About

A CLI tool to build beautiful rich text command-line interfaces with type validation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •