Skip to main content

Table of Contents
  1. About
  2. Quick Start
  3. Usage
  4. Development
  5. Contributing
  6. License

About

useCli A powerful Python CLI framework for building beautiful, developer-friendly command-line tools. It gives you:

  • Prefix matching — Type he instead of help
  • Interactive mode — Fuzzy finder for commands
  • Auto-generated help — Clean, styled output
  • Command scaffoldingmake:command generates boilerplate
  • UI components — Prompts, menus, styled console output

(back to top)

Quick Start

Install usecli with uv (recommended)

uv add usecli

Install with pip (alternative)

pip install usecli

Initialize

usecli init

Create a command

usecli make:command hello

Your new command is ready in the commands directory:

class HelloCommand(BaseCommand):
    def signature(self) -> str:
        return "hello"

    def description(self) -> str:
        return "Say hello"

    def handle(self, name: str = Argument(..., help="Your name")) -> None:
        console.print(f"Hello, {name}!")

Run it:

usecli hello world

(back to top)

Usage

Prefix Matching

Type partial command names:

usecli he          # help
usecli ma:co       # make:command

Interactive Mode

usecli --interactive    # Fuzzy finder for all commands
usecli -i hello         # Run 'hello' command interactively

Command Groups

Colon-separated commands group automatically in help:

def signature(self) -> str:
    return "db:migrate"

Displays as:

db:
  migrate    Run migrations
  backup     Backup database

Space-separated signatures create nested subcommands:

def signature(self) -> str:
    return "spec show"  # usecli spec show

JSON Output

Every command inherits --json; commands do not declare the option themselves. The flag works before or after a command name:

usecli --json about
usecli about --json

A successful invocation writes exactly one JSON document to stdout:

{"ok":true,"data":null}

A command can return any JSON-serializable value to populate data:

class StatusCommand(BaseCommand):
    def signature(self) -> str:
        return "status"

    def description(self) -> str:
        return "Show service status"

    def handle(self):
        return {"status": "ready", "workers": 3}

Failures preserve a non-zero exit status and use a stable error envelope:

{"ok":false,"error":{"type":"UsageError","message":"No such command","code":2}}

In JSON mode, stdout is reserved for that document. Human-facing output, including console.print() and ordinary print(), is routed to stderr. Prompts and confirmations resolve their declared defaults without reading stdin. A prompt without a default, menus, and --interactive fail immediately with a structured NonInteractiveError instead of blocking.

The existing fields ok, data, error, error.type, error.message, and error.code keep their names and types across compatible releases. New fields may be added.

UI Components

from usecli import Confirm, Menu, Prompt, console

console.print("[green]Done![/green]")
name = Prompt.ask("Enter name")
ok = Confirm.ask("Continue?")
choice = Menu.select(["A", "B", "C"])

Progress Indicators

Use Spinner when the amount of work is unknown and ProgressBar when a total is known:

from usecli import ProgressBar, Spinner

with Spinner("Loading records") as spinner:
    load_records()
    spinner.update("Indexing records")

with ProgressBar(total=len(items), description="Processing") as progress:
    for item in items:
        process(item)
        progress.advance()

Progress always renders to stderr, uses the active usecli theme, and is suppressed automatically in JSON mode, with quiet=True, or when stderr is not attached to a terminal. Calling commands do not need to detect these conditions.

Available Commands

about        Show app info
help         Show help
init         Initialize usecli (usecli only)
inspire      Random quote
make:command Create new command (usecli only)
make:theme   Create new theme (usecli only)

(back to top)

Development

See the Development Guide for setup, testing, and architecture details.

(back to top)

Contributing

Read the Contributing Guide.

Quick workflow:

  1. Fork and branch: git checkout -b feature/name
  2. Make changes
  3. Run checks: uv run poe clean-full
  4. Commit and push
  5. Open a Pull Request

(back to top)

License

MIT. See LICENSE.

(back to top)


Built by thememium

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usecli-0.1.77.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usecli-0.1.77-py3-none-any.whl (94.1 kB view details)

Uploaded Python 3

File details

Details for the file usecli-0.1.77.tar.gz.

File metadata

  • Download URL: usecli-0.1.77.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for usecli-0.1.77.tar.gz
Algorithm Hash digest
SHA256 8f1cd1437e50386177ee98c21fd5107af2a5f8c3d59e07fefdcf05c446ae13d1
MD5 6e36aaa66d53a035e0a22ff23581f063
BLAKE2b-256 61e57f2da851d9b72760750b717f7772741707b508b897e746fd12f9826038fb

See more details on using hashes here.

File details

Details for the file usecli-0.1.77-py3-none-any.whl.

File metadata

  • Download URL: usecli-0.1.77-py3-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for usecli-0.1.77-py3-none-any.whl
Algorithm Hash digest
SHA256 1583a9ecf5c3e9d201baaa29b69df3c08a881a8ad5ddf9049e8bb7a29c619f91
MD5 cd1693bc50cbd086aa3b8c62f5534679
BLAKE2b-256 3a9b1782478c196254df48b37400d36bed0d2127539a367c3002bf89caa55dcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page