Skip to main content

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_case names become --kebab-case flags automatically
  • Parameters without type annotations have their type inferred from the default value
  • *args and **kwargs are silently ignored
  • Both regular methods and @classmethod methods 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


Download files

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

Source Distribution

climplicit-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

climplicit-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

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

Hashes for climplicit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1a8e03ca69f4f7478e03ee9b62ff456ebfa71544ff24de3fccbf4cf9cc574c15
MD5 f8ed2f62ead51192a0a2a58db402fc1b
BLAKE2b-256 46918f4649e9ea7807d7574553af6d730f525697f6aba8efab293fdbb8a242f0

See more details on using hashes here.

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

Hashes for climplicit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee3d07904bb88257da892bc07aa42562fa9753d9d26216e093b91f3bd7499bda
MD5 e72f685d3a86db3d5891af222e0d4cb9
BLAKE2b-256 90916112e786c1f838406ec1bd6348b08df333eb3a8f34cd79961646b94d1029

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 Pingdom Monitoring Sentry Error logging StatusPage Status page