clicommands
Lightweight Python library for managing command-line commands with automatic discovery.
Features
- Automatic command discovery via
commands/directory or.commands.json - Two ways to define commands: function suffixed with
_commandorCommandclass - Argument parsing API:
classify_args,parse_args_from_config - Envfile loading:
ENVFILE_PATHsupport for loading.env - Built-in commands:
version,copy,varenv
Installation
pip install clicommands
Quick Start
- Create a
cli.pyin your package:
import sys
from pathlib import Path
from clicommands.helpers import cli_main
def main(argv=None):
cli_file_path = Path(__file__)
result = cli_main(cli_file_path, argv)
return int(result) if isinstance(result, (int, bool)) else (0 if result else 1)
if __name__ == "__main__":
sys.exit(main())
- Add a
commands/directory with your commands:
# commands/hello.py
def hello_command(args: list[str]) -> bool:
"""Say hello."""
print("Hello, world!")
return True
- Run:
python -m mypackage.cli hello
.commands.json Configuration
{
"packages": ["other_package"],
"directories": ["commands"],
"commands": []
}
packages: Packages to import commands fromdirectories: Paths to command directoriescommands: Additional commands
Documentation
docs/purpose.md— Purpose and use casesdocs/structure.md— Project organizationdocs/development.md— Development guidelinesdocs/AI.md— AI assistant contract
Metadata
Release files for clicommands 0.2.0
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 | |
|---|---|---|---|---|
| clicommands-0.2.0.tar.gz | 14.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clicommands-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.9 kB
Release files / clicommands-0.2.0.tar.gz
| Download URL | clicommands-0.2.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e00b3866a69ee1b770e48f65c86342c01f9883c41c206a683af11b7af7ebe038
|
|
BLAKE2b-256 checksum How to use checksums |
6fe5ed8cb5b6c9e0a6a2a3fefdd25cfbce6c198410fd5b8321519b2c94ccdfcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / clicommands-0.2.0-py3-none-any.whl
| Download URL | clicommands-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a37efffd79911198479b29e65395a82f87b26b962b8da3ec8eb4a139922e4cdc
|
|
BLAKE2b-256 checksum How to use checksums |
05b2abff7420d24320ac5c37db87e20293d286b3d1d071eb1c3b9d1999317f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logSecurity for clicommands 0.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for clicommands-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logA 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.