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
What's new in 0.2.0
- Introduced Resolved model layer
- Added parameter binding (
bind) - Added
validatecommand - Improved inheritance (
inherit_from) - Added support for relative paths (
../) - Improved help and dump output
- Introduced
_earlyparsing phase
✨ 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
- Event model (
- 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
Release history Release notifications | RSS feed
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 cli_def-0.2.0.tar.gz.
File metadata
- Download URL: cli_def-0.2.0.tar.gz
- Upload date:
- Size: 50.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6715d4911fd1802e87ab062a41e2df5e82d25aedf8a8be6e39095ecaf0c895c3
|
|
| MD5 |
3c6e3eb3592af9badf78892037caca2e
|
|
| BLAKE2b-256 |
c05ade37b37327fd7e75a8c15ed4d48a136c46b405a4edb6ad1dbfd1faefdd9c
|
File details
Details for the file cli_def-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cli_def-0.2.0-py3-none-any.whl
- Upload date:
- Size: 77.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef27a0b844fd0a3130fe49677cb228ea4b3e94a793d4f67f94a954eee52909f
|
|
| MD5 |
12bfcea83dbcaa2de55a0ef4e41592ff
|
|
| BLAKE2b-256 |
8f9d76494e5cafb2e5250ad05a4ad0a601f90dc1bda3116b606691c93a150970
|