Skip to main content

A declarative DSL for composable CLI applications with runtime and REPL

Project description

cli-def

A declarative DSL for defining CLI structures with a unified runtime and REPL for argparse/click backends.

project page: https://cli-def.tomesoft.net

source: https://github.com/tomesoft/cli-def

✨ Features

  • Define CLI structure declaratively (TOML / Python models)
  • Generate CLI implementations for:
    • argparse (standard library, no dependencies)
    • click (optional dependency)
  • Separation of:
    • CLI definition (DSL)
    • Runtime implementation (builders)
  • Built-in runtime system:
    • Event model (CliEvent)
    • Runner
    • Dispatcher
    • Entrypoint resolution (module:function)
    • Result propagation
  • Interactive REPL support
  • CLI chaining (execute one CLI from another)

📦 Installation

Core (argparse only)

pip install cli-def

With click support

pip install cli-def[click]

🚀 Quick Example

[cli]
key = "Your CLI"
help = "Help of your CLI"
prompt = "yourcli> "

[cli.echo]
args = [{key="message", mult="+"}]
cli-def run example.toml -- echo hello world

[run] forwarding args: ['echo', 'hello', 'world'], no_ctx_propagate: False
=== fallback handler ===
  PATH: ['Your CLI', 'echo']
  PARAMS: {'message': ['hello', 'world']}

🚀 Quick Start (Demo)

cli-def demo beginner

beginner profile reads in beginner.toml (see GitHub repository for details)

Type 'help' to list commands, 'exit' to exit
demo[beginner]> echo a b c d
a b c d

-> out[0]
demo[beginner]> greet John --upper
HELLO, JOHN!

-> out[1]

Advanced demo:

cli-def demo advanced

See profiles: https://github.com/tomesoft/cli-def/tree/main/src/cli_def/demo/profiles

🖥 Interactive Mode (REPL)

cli-def repl --file your_cli.toml
yourcli> help
yourcli> command arg1 --option value

🔁 Run Another CLI (CLI chaining)

cli-def run example.toml -- command arg1 arg2
  • -- separates cli-def arguments from the target CLI arguments
  • Remaining arguments are forwarded to the next CLI

📚 Documentation

Full documentation and design details are available on GitHub:

https://github.com/tomesoft/cli-def

  • DSL specification
  • Architecture
  • Examples
  • Development notes

📌 Roadmap

See TODO.md on GitHub: https://github.com/tomesoft/cli-def/blob/main/TODO.md

🤝 Contributing

Contributions are welcome!

📄 License

MIT License

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

cli_def-0.1.1.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

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

cli_def-0.1.1-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file cli_def-0.1.1.tar.gz.

File metadata

  • Download URL: cli_def-0.1.1.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cli_def-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9c91f2aacc6d4b390025c99342fb3dc5b0b88c9031c24b8a0bda26ce2a4c08f8
MD5 b31414a63f0f84c6d76eb759321bd7b1
BLAKE2b-256 9eb73ef818d70e17094537b64ef867d4447920e9cd08840fa3b3ece7ff0de884

See more details on using hashes here.

File details

Details for the file cli_def-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cli_def-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cli_def-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67d2df1757b823174a29c83a5f763f18b77f72d6e170c7379dfc4e0eaf6cdabd
MD5 4cea4a16db92dc6dbb0d66fe0e8f225a
BLAKE2b-256 ef815fdd5ea3c8bb2a027880115c2be1ceff12be28729c5eec35d24fcf1f3cd3

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