cli-fw
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.
Parse failures return Err[CliError]. Their source diagnostic is stored as
Option[Diagnostic], and a diagnostic help message is Option[str]; use
isinstance(value, Some) when inspecting either field directly, or call
Err.print_diagnostic() to render it.
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-errsforResult,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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_fw-0.0.6.tar.gz.
File metadata
- Download URL: cli_fw-0.0.6.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7c7a235dccd7d6821bdcf8ff204cf019d98719cf4716276c343d75a430e26a6
|
|
| MD5 |
8c71936b1362e0278d13046889651c63
|
|
| BLAKE2b-256 |
fe5faf904b5e2cf874af9c41971ec49695ad38337e46c18cc0dc71980f0ad60c
|
Provenance
The following attestation bundles were made for cli_fw-0.0.6.tar.gz:
Publisher:
release.yml on 0xveya/cli-fw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_fw-0.0.6.tar.gz -
Subject digest:
d7c7a235dccd7d6821bdcf8ff204cf019d98719cf4716276c343d75a430e26a6 - Sigstore transparency entry: 2470133855
- Sigstore integration time:
-
Permalink:
0xveya/cli-fw@55ce736c0a3bc82f7b4ac7b723a1d431699a5770 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/0xveya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55ce736c0a3bc82f7b4ac7b723a1d431699a5770 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cli_fw-0.0.6-py3-none-any.whl.
File metadata
- Download URL: cli_fw-0.0.6-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8c69b445bf8e65f19e7d8a198e9987b8b43f8c74ff6e440c914898dcafe6442
|
|
| MD5 |
00e3557d5ef1d1d12627c301f2756f94
|
|
| BLAKE2b-256 |
25145f9ef4ae727cbf542bbe2f1955dde05592356db5d7b5af03fc159696839f
|
Provenance
The following attestation bundles were made for cli_fw-0.0.6-py3-none-any.whl:
Publisher:
release.yml on 0xveya/cli-fw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_fw-0.0.6-py3-none-any.whl -
Subject digest:
f8c69b445bf8e65f19e7d8a198e9987b8b43f8c74ff6e440c914898dcafe6442 - Sigstore transparency entry: 2470134040
- Sigstore integration time:
-
Permalink:
0xveya/cli-fw@55ce736c0a3bc82f7b4ac7b723a1d431699a5770 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/0xveya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55ce736c0a3bc82f7b4ac7b723a1d431699a5770 -
Trigger Event:
push
-
Statement type: