Skip to main content

cli-fw

PyPI CI

View cli-fw on PyPI

A compact dataclass-driven command-line framework extracted from the Pacman and RAG projects.

uv add cli-fw

Example

from dataclasses import dataclass
from cli_fw import Command, arg


@dataclass
class Serve:
    port: int = arg(help="Port to listen on", default=8000)


command = Command("serve", schema=Serve)
parsed = command.execute(["--port", "8080"])

It supports positional and optional arguments, choices, booleans, lists, nested commands, generated help, and typed parse errors.

Commands and subcommands

Define arguments in dataclasses, attach each schema to a Command, then call execute(). A command callback receives the validated dataclass instance. A root command can contain any number of subcommands:

root = Command("project", short="Index and search a project")
root.add_command(Command("index", schema=Index, run=run_index))
root.add_command(Command("search", schema=Search, run=run_search))
result = root.execute()

Run it like python app.py index ./src --workers 8, or add --help at any command level. See the complete runnable subcommand example, including positional values, defaults, boolean flags, callbacks, and diagnostic handling.

Where I use it

This is my internal CLI framework for 42 projects. The latest implementation was extracted from Pacman, a work-in-progress group project in the 42 organization, with behavior checked against RAG Against the Machine. Pacman uses it for the game command and RAG uses it to validate command syntax and produce diagnostics before command execution.

Dependencies

  • Python 3.10+
  • typed-errs for Result, Err, and diagnostics

Use and contributions

This is a personal library, but it is not private or locked to my projects. You may use it in general Python work and in 42 projects under the MIT license; just follow the rules that apply to your campus and assignment.

Contributions are welcome: open an issue or send a pull request. I do not care whether a contribution is written by hand, AI-assisted, or generated another way; I care about whether it is correct, tested, understandable, and a good fit. Because this is opinionated personal infrastructure, pull requests are reviewed selectively and are likely to be rejected unless they clearly improve the library without making it harder to maintain.

Development and release

Run mise run check. Every push to master publishes a unique 0.0.<CI run> ZeroVer version through PyPI Trusted Publishing. mise run publish remains available.

Download files

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

Source Distribution

cli_fw-0.0.4.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

cli_fw-0.0.4-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file cli_fw-0.0.4.tar.gz.

File metadata

  • Download URL: cli_fw-0.0.4.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cli_fw-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d198c2d158a4164a42be2af046d47fc1922c73b0a36b17b13f1b17c6ec4c3a69
MD5 091aa105f4f0adeafc61b99a1fe22391
BLAKE2b-256 d656c130d1ae7f60a9ea43601928ca0c78bc48d3a4226590186ac35013ff73c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cli_fw-0.0.4.tar.gz:

Publisher: release.yml on 0xveya/cli-fw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cli_fw-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: cli_fw-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cli_fw-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 430b0ec50f3cfb5152b47f7ee51fdd8b6947b3810ab85ea986a2fff85538a788
MD5 9c56d7e8f4c7f5200d2a0c65dbbe6a3c
BLAKE2b-256 389a9d89f4ffdf83b01d74ed414bf05bf59031b6abfb0dd33d8c3c869044c625

See more details on using hashes here.

Provenance

The following attestation bundles were made for cli_fw-0.0.4-py3-none-any.whl:

Publisher: release.yml on 0xveya/cli-fw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.6

2 files

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

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