Skip to main content

Clir

A modern CLI toolkit for building beautiful terminal applications in Python.

Features

  • Command Framework - Decorator-based command registration with type-annotated arguments
  • Advanced Options - Repeatable options, fixed-arity options, and flag-to-parameter aliasing
  • Rich Terminal Output - Colored text, tables, panels, progress bars, and spinners
  • Interactive Prompts - Text input, confirmation dialogs, and selection prompts
  • Type Inference - Automatically infer argument types from function signatures
  • Async Support - Commands can be async functions
  • Testing Utilities - Built-in tools for testing CLI applications

Installation

pip install pyclir

pyclir is the PyPI distribution name; the import package is clir (import clir). The name clir was already taken on PyPI.

Quick Start

from clir import ClirApp, argument, option
from clir.output import success, error, Table

app = ClirApp(
    name="mycli",
    description="My awesome CLI",
)

@app.command()
@argument("name")
@option("--count", "-c", default=1)
def greet(name: str, count: int):
    """Greet someone warmly."""
    for _ in range(count):
        success(f"Hello, {name}!")

@app.command()
def status():
    """Show system status."""
    t = Table("Component", "Status")
    t.add_row("Database", "Connected")
    t.add_row("API", "Running")
    t.show()

if __name__ == "__main__":
    app.run()

Advanced Options

@option supports repeatable options, fixed-arity options, and binding a flag to a differently-named Python parameter.

from pathlib import Path
from clir import ClirApp, argument, option

app = ClirApp(name="mycli")

@app.command()
# Repeatable: pass --salvage more than once; values collect into a list.
@option("--salvage", multiple=True, default=None, help="Salvage file (repeatable)")
# Fixed-arity: --compare A B consumes exactly two values.
@option("--compare", nargs=2, default=None, help="Two models to compare")
# dest-aliasing: the CLI flag is --in, the function parameter is in_path.
@option("--in", dest="in_path", help="Input file")
# pathlib.Path is a supported type; the function receives a Path.
@option("--out", type=Path, default=None, help="Output path")
def run(salvage, compare, in_path, out):
    # mycli run --salvage a.jsonl --salvage b.jsonl --compare m1 m2 --in data.txt
    #   salvage == ["a.jsonl", "b.jsonl"]   (None when not passed)
    #   compare == ["m1", "m2"]             (None when not passed)
    #   in_path == "data.txt"
    ...
  • multiple=True — the option may be passed repeatedly; every value is collected into a list. Use default=None to distinguish "not passed" from "passed empty".
  • nargs=N — the option consumes exactly N values at once; the bound value is an N-element list. Combine with multiple=True for a list of fixed-length lists.
  • dest="..." — binds the option (or argument) to a Python parameter whose name differs from the flag spelling — useful when the flag would be a Python keyword (--in, --class). Works on @argument too.
  • type= — str, int, float, bool, and pathlib.Path are all supported; for list-valued options the type converts each element.

Output Functions

from clir.output import success, error, warning, info, debug, Table, Panel

success("Operation completed!")  # Green bold
error("Something went wrong")     # Red bold
warning("Be careful")             # Yellow bold
info("Here's some info")          # Cyan
debug("Debug message")            # Dim

# Tables
t = Table("Name", "Age")
t.add_row("Alice", "30")
t.add_row("Bob", "25")
t.show()

# Panels
Panel("Content", title="My Panel").show()

Interactive Prompts

from clir.prompts import prompt, confirm, select

# Text input
name = prompt("What is your name?")

# Confirmation
if confirm("Continue?", default=True):
    print("Continuing!")

# Selection
choice = select("Choose:", ["Option 1", "Option 2", "Option 3"])

Testing

from clir import ClirApp
from clir.testing import CliRunner

app = ClirApp(name="test")

@app.command()
def hello():
    print("Hello!")

runner = CliRunner(app)
result = runner.invoke(["hello"])

assert result.exit_code == 0
assert "Hello" in result.output

License

MIT

Metadata

Release files for pyclir 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyclir 0.2.2
File Size Uploaded Provenance Actions
pyclir-0.2.2.tar.gz 64.6 kB With provenance Details for pyclir-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyclir 0.2.2
File Interpreter ABI Platform Actions
pyclir-0.2.2-py3-none-any.whl Python 3 none any Details for pyclir-0.2.2-py3-none-any.whl

Total release size: 127.8 kB

Release files / pyclir-0.2.2.tar.gz

Download URL pyclir-0.2.2.tar.gz
Size 64.6 kB
Tags Source
SHA-256 checksum
How to use checksums
674e7fe5ae6aac34320d44a7678726fa8a69021fef6669a0abf73bd0c0d14091
BLAKE2b-256 checksum
How to use checksums
f6cf95135ab3c8814c8d33c8c5c719a512d4e3724fc9980457a39f333bf95351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 17, 2026.

Transparency log

Release files / pyclir-0.2.2-py3-none-any.whl

Download URL pyclir-0.2.2-py3-none-any.whl
Size 63.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e87b6834215ae421a915e558dd5bbcfed095ae4e192fa4413dd7945ceff1c951
BLAKE2b-256 checksum
How to use checksums
6864775f7d634e3af19d8c4794c7641210fe4417dac0bcc6220434df3ae5019b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 17, 2026.

Transparency log

Security for pyclir 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyclir-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page