Clak
Clak (Command Line avec Klass) is a Python library for building command-line
interfaces with a class-based API on top of standard argparse. Nested
commands, arguments, and optional batteries (views, logging, config, completion)
stay close to what you already know from the stdlib.
Full docs: mrjk.github.io/python-clak · PyPI: mrjk.clak
Features
- Class-based CLI — define apps with
Parser,Argument, andCommand; no new DSL - Argparse-native — same argument syntax as
add_argument()/ subparsers - Nested commands — git-like trees with inheritance and a command overview in
--help - Optional components — views, logging, XDG config, shell-completion script generation
- Light core; extras only when you need them (
colors,config,markdown,rst)
Requirements
- Python 3.10–3.14 (declared
>=3.10,<4.0; CI and local matrix cover 3.10–3.14) argparse(stdlib)
Developer setup and the version matrix: Development setup.
Install
pip install mrjk.clak
# Or with your project manager
poetry add mrjk.clak
pdm add mrjk.clak
uv add mrjk.clak
Optional:
pip install 'mrjk.clak[colors]' # coloredlogs for LoggingOptMixin
pip install 'mrjk.clak[config]' # PyYAML for YAML config / --format yaml
pip install 'mrjk.clak[markdown]' # rich for MarkdownView and colored --help
pip install 'mrjk.clak[rst]' # docutils for RstView
Quick start
from clak import Argument, Command, Parser
class ShowCommand(Parser):
"""Show something."""
target = Argument("--target", "-t", help="Target to show")
format = Argument(
"--format", choices=["json", "text"], help="Output format"
)
def cli_run(self, target=None, format=None, **_):
print(f"show target={target} format={format}")
class MainApp(Parser):
"""Demo application."""
debug = Argument("--debug", action="store_true", help="Enable debug mode")
config = Argument("--config", "-c", help="Config file path")
show = Command(ShowCommand, help="Show something")
# Instantiating the root parser parses argv and runs the matching command.
if __name__ == "__main__":
MainApp()
$ python demo.py --help
usage: demo.py [-h] [--debug] [--config CONFIG] {show} ...
Key concepts
Arguments
class MyCommand(Parser):
verbose = Argument("-v", "--verbose", action="store_true", help="Verbose")
Nested commands
Command binds a child Parser (aliases: SubParser, SubCommand, Cmd):
class MainApp(Parser):
status = Command(StatusCommand, help="Show status")
Optional components
| Component | Mixin / class | Docs |
|---|---|---|
| Tables / structured output | ListViewMixin, ShowViewMixin, PprintViewMixin |
Views |
Colored --help |
default (Rich extra, TTY) | Colored help |
Logging + -v |
LoggingOptMixin |
Logging |
| XDG paths + config file | XDGConfigMixin |
Config |
| Shell completion scripts | CompCmdRender |
Completion |
Learn more
- Installation and Quickstart
- Guides under
docs// the site Guides tab - Pasteable AI context: primer · reference
- Runnable examples in
examples/ - Planned work: Roadmap
Contributing
Bug reports, questions, and PRs are welcome. See the contribution guidelines
in the documentation (or CONTRIBUTING.md).
License
GPL v3.
Metadata
Release files for mrjk.clak 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mrjk_clak-0.6.1.tar.gz | 84.8 kB | Without provenance | Details for mrjk_clak-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mrjk_clak-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for mrjk_clak-0.6.1-py3-none-any.whl |
Total release size: 188.6 kB
Release files / mrjk_clak-0.6.1.tar.gz
| Download URL | mrjk_clak-0.6.1.tar.gz |
|---|---|
| Size | 84.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
240fd5aed91eac53efd3552b0fd639ab18082b3863561a133e823d92e5276437
|
|
BLAKE2b-256 checksum How to use checksums |
419967a06b5e6bb859c215add4454b85ad3386e94fdfd48c8403d86576219b71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.3 Linux/6.17.0-1022-azure
|
Release files / mrjk_clak-0.6.1-py3-none-any.whl
| Download URL | mrjk_clak-0.6.1-py3-none-any.whl |
|---|---|
| Size | 103.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce4f1e3579a607175e50fe61ba7177a6b4ebc8cd45e06aba193ba43031a6ed79
|
|
BLAKE2b-256 checksum How to use checksums |
1641f1265aa9051432b5df794b8fbce2dfdfe55e36fd9997f77278f5ff468ab0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.3 Linux/6.17.0-1022-azure
|
Security for mrjk.clak 0.6.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.