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

pip install mcl-tool

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.1.0.tar.gz (14.2 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.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mcl_tool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eeaad097d8bd232088b094627546fb7501340a5c40d32ad80d2320c9c46a2fb5
MD5 fa81f402abe2d58a33e88a463ec30804
BLAKE2b-256 480c50a5654efccffebec5177d8a021c3bc4e877f4a21e322ba6053d24436426

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcl_tool-0.1.0-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.0

File hashes

Hashes for mcl_tool-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 310b3e2bf05457c57473952facfef6a7ce974306164aeb84c9afc0937dceab21
MD5 a1433e5dc4c25d1a63c9c5c8a61fd6a3
BLAKE2b-256 309dfac1b095ce1bde418d872fe19406d8ce58061a93890f351bd4dd3860a6f4

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