My Command Line: A personal generic customizable CLI tool
Project description
⚡ mcl-tool — My Command Line
Turn JSON recipes into powerful automation scripts. Write once, run everywhere.
A lightweight, batteries-included CLI that makes command automation effortless. Compose reusable scripts with variables, nested flows, and safe execution—all stored in simple JSON.
✨ Why mcl-tool?
| Feature | Description |
|---|---|
| 🎯 Composable scripts | Author commands once in JSON and call them from anywhere. |
| 🔄 Args & vars | Mix positional placeholders ($1, $2) with config vars and optional fragments. Use $$ to escape literal $. |
| 🎲 Nested flows | Navigate nested script structures via space notation: mcl example date utc. Consistent display and execution. |
| 🛡️ Safe execution | Dry-run mode, opt-in environment sharing, structured logging. |
| 📐 Developer-friendly | Strict type hints, comprehensive test coverage, mypy/black enforced in CI. |
| 🔓 Open source | MIT-licensed; fork, adapt, and redistribute freely with attribution. |
Installation
Recommended: pipx (macOS / Linux)
The easiest way to get started—pipx manages isolation and PATH for you:
pipx install mcl-tool
Alternative: virtual environment
If you prefer managing the venv yourself:
- Ensure Python 3.8+ is available (
python3 --version). - Create and activate an isolated environment:
python3 -m venv ~/.venvs/mcl source ~/.venvs/mcl/bin/activate python -m pip install --upgrade pip
- Install the CLI:
pip install mcl-tool
Quick Start
- Initialize a project config
mcl init - Edit
mcl.json(local overrides global~/.mcl/global-mcl.json):{ "vars": { "project": "mcl", "version": "0.1.0" }, "scripts": { "example": { "hello": "echo Hello, $1!", "deploy": ["echo Deploying $project", "?$1", "echo Version $version"], "date": { "show": "date", "utc": "date -u" } } } }
- Run commands
mcl # Shows interactive menu or list: # • example hello # • example deploy # • example date show # • example date utc mcl example hello Alice # Execute with spaces mcl example deploy staging # Optional arg substituted into '?$1' mcl example date utc # Nested command mcl --dry-run example date utc # Dry-run mode
Demo
Command Reference
| Command | Description |
|---|---|
mcl init |
Create a stub mcl.json without overwriting existing files. |
mcl edit |
Open the global config (~/.mcl/global-mcl.json) in $EDITOR. |
mcl run <script> [args...] |
Execute a script node; errors bubble as ValueError for clean Click aborts. |
mcl <script> [args...] |
Shorthand for mcl run ..., including nested paths (mcl example date utc). |
--dry-run |
Print rendered commands without executing. |
--share-vars |
Export config vars and args as env vars for shell-based scripts. |
Configuration Notes
- Scripts accept strings, ordered lists, or nested objects; comment lines starting with
#are ignored. - Nested scripts notation: Scripts are displayed AND executed with space-separated paths (e.g.,
example hello,docker build). Use spaces to invoke nested commands. - Positional placeholders (
$1,$2, …) map to CLI args; optional placeholders (?$3) drop when missing. - Escape syntax: Use
$$to output a literal$without substitution. For example,$$1becomes$1in the output (useful when generating shell scripts that use their own parameters). - Config vars become substitutions (
$project) and, with--share-vars, exported env vars (project,MCL_ARG_1, …). - Global config lives in
~/.mcl/global-mcl.json; localmcl.jsonoverrides keys during merge. - Running
mclwith no args shows an interactive menu (TTY) or text list with available scripts.
🎯 Interactive Subcommand Selection
When you execute a nested command without specifying a subcommand, mcl shows an interactive menu in TTY environments:
$ mcl docker
? Select a subcommand for 'docker':
❯ build
run
stop
logs
Navigate with arrow keys (↑/↓) and select with Enter. Press Ctrl+C to cancel.
Behavior:
- Interactive terminal (TTY): Shows an interactive menu with arrow key navigation
- Non-interactive (pipes, scripts, CI/CD): Falls back to error message with available options
- Graceful cancellation: Ctrl+C exits cleanly with a "cancelled by user" message
This feature improves discoverability while maintaining full backward compatibility for automation workflows.
Development
- Create an environment:
python -m venv .venv && source .venv/bin/activate - Install dev extras:
pip install -e '.[dev]' - Run quality gates:
black --check . mypy src tests pytest --cov=src/mcl
- GitHub Actions (
.github/workflows/ci.yml) mirrors these steps.
See docs/architecture.md for a deep dive into the CLI → Config → Executor pipeline, and docs/testing.md for pytest tips. Contribution guidelines live in CONTRIBUTING.md.
Roadmap
- Config schema validation (Pydantic).
- Optional YAML support.
- Multi-platform test matrix via tox.
Have ideas? Open an issue or PR! 🎉
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
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 mcl_tool-0.4.0.tar.gz.
File metadata
- Download URL: mcl_tool-0.4.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09a68f6f57727e9dbe6b89f8ebe86695ba433f9c7cef79423f86c3167ea787f9
|
|
| MD5 |
c7de91e68d37327b3580ca6d7f772b1a
|
|
| BLAKE2b-256 |
46a1ce86dd41d81be4aa408146cc876dff83fe53411701f04a5e3ea74b47c29d
|
File details
Details for the file mcl_tool-0.4.0-py3-none-any.whl.
File metadata
- Download URL: mcl_tool-0.4.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eb7616b107583917321c2a859916cd2fd4e8b4317a53555acc5f12aba3d1ec7
|
|
| MD5 |
cb743229bf9a2e3015b9ab55c642a413
|
|
| BLAKE2b-256 |
329355854035c86781e62724c0252e9be3d49913e2912c6f2f0374cd680e5927
|