Skip to content

Typer

Modern CLI framework for Python that helps you build beautiful command-line interfaces.

Overview

Typer is a library for building CLI applications that helps you build great CLIs with minimal code based on Python type hints.

Features

  • Based on Python type hints
  • Automatic help generation
  • Validation and autocompletion
  • Rich output formatting
  • Subcommands support
  • Async support

Getting Started

bash
pip install typer

Basic Example

python
import typer

app = typer.Typer()

@app.command()
def hello(name: str):
    """Say hello to NAME."""
    typer.echo(f"Hello {name}!")

@app.command()
def goodbye(name: str, formal: bool = False):
    """Say goodbye to NAME."""
    if formal:
        typer.echo(f"Goodbye Ms. {name}. Have a good day.")
    else:
        typer.echo(f"Bye {name}!")

if __name__ == "__main__":
    app()

PAPER-CODE Integration

PAPER-CODE provides:

  • Typer project templates
  • CLI best practices
  • Testing configurations
  • Distribution setup

Resources