Metadata-Version: 2.4
Name: cli-def
Version: 0.1.1
Summary: A declarative DSL for composable CLI applications with runtime and REPL
Author: Tomesoft
License: MIT License
        
        Copyright (c) 2026 Tomesoft
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to do so, subject to the
        following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://cli-def.tomesoft.net
Project-URL: Repository, https://github.com/tomesoft/cli-def
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: wcwidth
Provides-Extra: click
Requires-Dist: click>=8.0; extra == "click"
Provides-Extra: repl
Requires-Dist: prompt_toolkit; extra == "repl"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# 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)

```bash
pip install cli-def
```

With click support

```bash
pip install cli-def[click]
```

## 🚀 Quick Example

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

[cli.echo]
args = [{key="message", mult="+"}]
```

```bash
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)

```bash
cli-def demo beginner
```

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

```text
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:

```bash
cli-def demo advanced
```

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

## 🖥 Interactive Mode (REPL)

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

## 🔁 Run Another CLI (CLI chaining)

```bash
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

