Derive CLIs implicitly from decorators.
Project description
climplicit
Derive CLI tools implicitly from Python class definitions. Decorate a class with @tool, mark methods with @command, and the CLI is derived from type annotations automatically.
Defining a tool
from climplicit import command, tool
from pathlib import Path
@tool("file-processor", desc="Process and inspect text files")
class FileProcessor:
@command
def convert(
self,
input_file: Path,
output_file: Path,
encoding: str = "utf-8",
uppercase: bool = False,
max_lines: int | None = None,
):
"""Convert a text file, optionally transforming its content."""
...
@command
def inspect(self, input_file: Path, verbose: bool = False):
"""Print metadata and a preview of a text file."""
...
$ file-processor --help
usage: file-processor <command> [options]
│ Process and inspect text files
options:
-h, --help show this help message and exit
commands:
convert Convert a text file, optionally transforming its content.
inspect Print metadata and a preview of a text file.
$ file-processor convert --help
usage: file-processor convert input-file output-file [options]
│ Convert a text file, optionally transforming its content.
positional arguments:
input-file
output-file
options:
-h, --help show this help message and exit
--encoding STR ['utf-8']
--uppercase
--max-lines INT [None]
How annotations map to CLI behaviour
| Parameter | CLI |
|---|---|
name: str |
positional name (required) |
path: Path |
positional path (required) |
count: int = 10 |
--count INT (default: 10) |
verbose: bool = False |
--verbose flag |
limit: int | None = None |
--limit INT (default: None) |
snake_casenames become--kebab-caseflags automatically- Parameters without type annotations have their type inferred from the default value
*argsand**kwargsare silently ignored- Both regular methods and
@classmethodmethods are supported
Single-command shortcut
If a tool defines only one @command, the subcommand layer is skipped entirely:
@tool("greet")
class Greeter:
@command
def hello(self, name: str, loud: bool = False):
"""Greet someone."""
...
$ greet World --loud # no "hello" subcommand needed
Installing tools into a venv
climplicit writes scripts directly into the active venv's bin/ on demand — no hardcoded entry points, no reinstall loop.
climplicit-generate <source-root>
<source-root> is the directory containing your packages (equivalent to where in find_namespace_packages). Sibling directories at the same level are also added to sys.path, so shared packages like util/ resolve correctly.
Re-run whenever you add a new @tool class.
Packaging for distribution
To print the [project.scripts] block for all @tool classes in a folder:
climplicit-generate <source-root> --print-scripts
Paste the output into your pyproject.toml and pip will create the scripts on install.
Before climplicit is on PyPI
Until climplicit is published, pip install -e . won't find it in the isolated build environment. Workaround:
pip install -e /path/to/climplicit # install climplicit into your venv first
pip install --no-build-isolation -e . # reuse the active venv for building
Or use the helper script:
/path/to/climplicit/scripts/dev-install.sh /path/to/your/project
Project details
Release history Release notifications | RSS feed
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 climplicit-0.1.1.tar.gz.
File metadata
- Download URL: climplicit-0.1.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a8e03ca69f4f7478e03ee9b62ff456ebfa71544ff24de3fccbf4cf9cc574c15
|
|
| MD5 |
f8ed2f62ead51192a0a2a58db402fc1b
|
|
| BLAKE2b-256 |
46918f4649e9ea7807d7574553af6d730f525697f6aba8efab293fdbb8a242f0
|
File details
Details for the file climplicit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: climplicit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee3d07904bb88257da892bc07aa42562fa9753d9d26216e093b91f3bd7499bda
|
|
| MD5 |
e72f685d3a86db3d5891af222e0d4cb9
|
|
| BLAKE2b-256 |
90916112e786c1f838406ec1bd6348b08df333eb3a8f34cd79961646b94d1029
|