Skip to main content

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 validate command
  • Improved inheritance (inherit_from)
  • Added support for relative paths (../)
  • Improved help and dump output
  • Introduced _early parsing 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
  • Interactive REPL support
  • CLI chaining (execute one CLI from another)

📦 Installation

Requires Python 3.12 or later.

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

Metadata

Release files for cli-def 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cli-def 0.2.1
File Size Uploaded Provenance Actions
cli_def-0.2.1.tar.gz 55.5 kB Without provenance Details for cli_def-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cli-def 0.2.1
File Interpreter ABI Platform Actions
cli_def-0.2.1-py3-none-any.whl Python 3 none any Details for cli_def-0.2.1-py3-none-any.whl

Total release size: 139.9 kB

Release files / cli_def-0.2.1.tar.gz

Download URL cli_def-0.2.1.tar.gz
Size 55.5 kB
Tags Source
SHA-256 checksum
How to use checksums
738c2e6d860aee026e17d7b039c5a67239b83f52470201bbd8d244c400f3d046
BLAKE2b-256 checksum
How to use checksums
4369d7c8906fc3560da895fdac1054e187cfb150e60d7dfebdea7ca517e753a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / cli_def-0.2.1-py3-none-any.whl

Download URL cli_def-0.2.1-py3-none-any.whl
Size 84.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9aa87db10c9dc100abf3cfa4922855421135c511765f5e5e566534197b2a63c
BLAKE2b-256 checksum
How to use checksums
831ce978ca01070e90c59e4d260fd115bf23126b4e33144cfcba4b3aa2c1fad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for cli-def 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page