Skip to main content

My Command Line: A personal generic customizable CLI tool

Project description

mcl-tool — My Command Line

A batteries-included CLI that turns JSON recipes into reusable automation scripts.

Author: Emanuele Strazzullo

  • Dev friendly – strict type hints, pytest coverage, mypy/black enforced in CI.
  • Open source – licensed under MIT, free to fork, adapt, and redistribute with attribution.

PyPI License CI

Why mcl-tool?

  • Composable scripts – author commands once in JSON and call them from anywhere.
  • Args & vars aware – mix positional placeholders ($1, $2) with named variables and optional fragments (?$1).
  • Nested flows – drill into structures like example.date.utc via mcl example date utc.
  • Safe execution – dry-run mode, opt-in environment sharing, structured logging.
  • Dev friendly – strict type hints, pytest coverage, mypy/black enforced in CI.

Installation

macOS / Linux (virtual environment recommended)

  1. Ensure Python 3.10+ is available (python3 --version).
  2. If venv is missing, install it (e.g. sudo apt install python3-venv on Debian/Ubuntu or brew install python@3.11 on macOS).
  3. Create and activate an isolated environment:
    python3 -m venv ~/.venvs/mcl
    source ~/.venvs/mcl/bin/activate
    python -m pip install --upgrade pip
    
  4. Install the CLI inside the environment:
    pip install mcl-tool
    

System-wide install via pipx

If you prefer a standalone binary-like install, use pipx:

pipx install mcl-tool

This keeps mcl isolated while exposing the command on your PATH.

Quick Start

  1. Initialize a project config
    mcl init
    
  2. 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"
    			}
    		}
    	}
    }
    
  3. Run commands
    mcl example hello Alice      # -> echo Hello, Alice!
    mcl example deploy staging  # -> optional arg substituted into '?$1'
    mcl --dry-run example date utc
    mcl                        # -> shows available scripts from global + local config
    

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.
  • Positional placeholders ($1, $2, …) map to CLI args; optional placeholders (?$3) drop when missing.
  • Config vars become substitutions ($project) and, with --share-vars, exported env vars (project, MCL_ARG_1, …).
  • Global config lives in ~/.mcl/global-mcl.json; local mcl.json overrides keys during merge.
  • Running mcl with no args prints local scripts first (overrides highlighted) and global scripts second for quick discovery.

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

mcl_tool-0.2.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

mcl_tool-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file mcl_tool-0.2.0.tar.gz.

File metadata

  • Download URL: mcl_tool-0.2.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcl_tool-0.2.0.tar.gz
Algorithm Hash digest
SHA256 85b8def3a1d3faf471465dc7df967d231ab1a93960aa69da77c18afafb30c872
MD5 ecd35d5c0795cec6367538321655360d
BLAKE2b-256 9e6722e4d49f152d590e53ce18a94ae0e882ec46fbc5114f11742fed53fa5a5c

See more details on using hashes here.

File details

Details for the file mcl_tool-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mcl_tool-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcl_tool-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2668158f6714d1ba868a1f6fd43ac6505c0bc250517d13cbe7f39968ff3956d
MD5 42cba564724e2807c1d438717c05ac81
BLAKE2b-256 8119155897c99991c343a615e01ebfc3ce0a4dea17438899e5c5cfa864ed3d79

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