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
- 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
- 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)
Core (argparse only)
pip install cli-defWith click support
pip install cli-def[click][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']}cli-def demo beginnerbeginner 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 advancedSee profiles: https://github.com/tomesoft/cli-def/tree/main/src/cli_def/demo/profiles
cli-def repl --file your_cli.toml
yourcli> help
yourcli> command arg1 --option valuecli-def run example.toml -- command arg1 arg2--separates cli-def arguments from the target CLI arguments- Remaining arguments are forwarded to the next CLI
Full documentation and design details are available on GitHub:
https://github.com/tomesoft/cli-def
- DSL specification
- Architecture
- Examples
- Development notes
See TODO.md on GitHub: https://github.com/tomesoft/cli-def/blob/main/TODO.md
Contributions are welcome!
MIT License