cli-def 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cli_def-0.1.1/PKG-INFO +177 -0
- cli_def-0.1.1/README.md +133 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/pyproject.toml +1 -1
- cli_def-0.1.1/src/cli_def.egg-info/PKG-INFO +177 -0
- cli_def-0.1.0/PKG-INFO +0 -400
- cli_def-0.1.0/README.md +0 -356
- cli_def-0.1.0/src/cli_def.egg-info/PKG-INFO +0 -400
- {cli_def-0.1.0 → cli_def-0.1.1}/LICENSE +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/setup.cfg +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/argparse/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/argparse/argparse_builder.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/click/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/click/click_binder.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/click/click_builder.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/backend/protocols.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/demo/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/demo/handlers.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/demo/profiles/advanced.toml +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/demo/profiles/beginner.toml +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/abstract_node.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/argument_def.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/cli_def.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/command_def.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/mult_def.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/models/schema/cli_schema.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/dumper.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/loader.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/utils/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/utils/pretty_renderer.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/utils/renderer.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/ops/utils/renderer_ops.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/parsers/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/parsers/parser.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/resources/cli_def.toml +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/_internal/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/_internal/scan_runner.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/context.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/dispatcher.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/event.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/handler_support.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/result.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/runner.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/scanner.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/session.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/runtime/utils.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/common.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/__init__.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/dummy.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/dummy2.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/dump.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/repl.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/run.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/scan.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/handlers/search.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def/script/main.py +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def.egg-info/SOURCES.txt +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def.egg-info/dependency_links.txt +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def.egg-info/entry_points.txt +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def.egg-info/requires.txt +0 -0
- {cli_def-0.1.0 → cli_def-0.1.1}/src/cli_def.egg-info/top_level.txt +0 -0
cli_def-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cli-def
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A declarative DSL for composable CLI applications with runtime and REPL
|
|
5
|
+
Author: Tomesoft
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Tomesoft
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to do so, subject to the
|
|
15
|
+
following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://cli-def.tomesoft.net
|
|
28
|
+
Project-URL: Repository, https://github.com/tomesoft/cli-def
|
|
29
|
+
Classifier: Programming Language :: Python :: 3
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.10
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: wcwidth
|
|
37
|
+
Provides-Extra: click
|
|
38
|
+
Requires-Dist: click>=8.0; extra == "click"
|
|
39
|
+
Provides-Extra: repl
|
|
40
|
+
Requires-Dist: prompt_toolkit; extra == "repl"
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: pytest; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# cli-def
|
|
46
|
+
|
|
47
|
+
A declarative DSL for defining CLI structures with a unified runtime and REPL for argparse/click backends.
|
|
48
|
+
|
|
49
|
+
project page:
|
|
50
|
+
https://cli-def.tomesoft.net
|
|
51
|
+
|
|
52
|
+
source:
|
|
53
|
+
https://github.com/tomesoft/cli-def
|
|
54
|
+
|
|
55
|
+
## ✨ Features
|
|
56
|
+
|
|
57
|
+
- Define CLI structure declaratively (TOML / Python models)
|
|
58
|
+
- Generate CLI implementations for:
|
|
59
|
+
- `argparse` (standard library, no dependencies)
|
|
60
|
+
- `click` (optional dependency)
|
|
61
|
+
- Separation of:
|
|
62
|
+
- CLI definition (DSL)
|
|
63
|
+
- Runtime implementation (builders)
|
|
64
|
+
- Built-in runtime system:
|
|
65
|
+
- Event model (`CliEvent`)
|
|
66
|
+
- Runner
|
|
67
|
+
- Dispatcher
|
|
68
|
+
- Entrypoint resolution (`module:function`)
|
|
69
|
+
- Result propagation
|
|
70
|
+
- Interactive REPL support
|
|
71
|
+
- CLI chaining (execute one CLI from another)
|
|
72
|
+
|
|
73
|
+
## 📦 Installation
|
|
74
|
+
|
|
75
|
+
Core (argparse only)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install cli-def
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
With click support
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install cli-def[click]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 🚀 Quick Example
|
|
88
|
+
|
|
89
|
+
```toml
|
|
90
|
+
[cli]
|
|
91
|
+
key = "Your CLI"
|
|
92
|
+
help = "Help of your CLI"
|
|
93
|
+
prompt = "yourcli> "
|
|
94
|
+
|
|
95
|
+
[cli.echo]
|
|
96
|
+
args = [{key="message", mult="+"}]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
cli-def run example.toml -- echo hello world
|
|
101
|
+
|
|
102
|
+
[run] forwarding args: ['echo', 'hello', 'world'], no_ctx_propagate: False
|
|
103
|
+
=== fallback handler ===
|
|
104
|
+
PATH: ['Your CLI', 'echo']
|
|
105
|
+
PARAMS: {'message': ['hello', 'world']}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 🚀 Quick Start (Demo)
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
cli-def demo beginner
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
beginner profile reads in beginner.toml (see GitHub repository for details)
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
Type 'help' to list commands, 'exit' to exit
|
|
118
|
+
demo[beginner]> echo a b c d
|
|
119
|
+
a b c d
|
|
120
|
+
|
|
121
|
+
-> out[0]
|
|
122
|
+
demo[beginner]> greet John --upper
|
|
123
|
+
HELLO, JOHN!
|
|
124
|
+
|
|
125
|
+
-> out[1]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Advanced demo:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
cli-def demo advanced
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See profiles:
|
|
135
|
+
https://github.com/tomesoft/cli-def/tree/main/src/cli_def/demo/profiles
|
|
136
|
+
|
|
137
|
+
## 🖥 Interactive Mode (REPL)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cli-def repl --file your_cli.toml
|
|
141
|
+
yourcli> help
|
|
142
|
+
yourcli> command arg1 --option value
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 🔁 Run Another CLI (CLI chaining)
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cli-def run example.toml -- command arg1 arg2
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- `--` separates cli-def arguments from the target CLI arguments
|
|
152
|
+
- Remaining arguments are forwarded to the next CLI
|
|
153
|
+
|
|
154
|
+
## 📚 Documentation
|
|
155
|
+
|
|
156
|
+
Full documentation and design details are available on GitHub:
|
|
157
|
+
|
|
158
|
+
https://github.com/tomesoft/cli-def
|
|
159
|
+
|
|
160
|
+
- DSL specification
|
|
161
|
+
- Architecture
|
|
162
|
+
- Examples
|
|
163
|
+
- Development notes
|
|
164
|
+
|
|
165
|
+
## 📌 Roadmap
|
|
166
|
+
|
|
167
|
+
See TODO.md on GitHub:
|
|
168
|
+
https://github.com/tomesoft/cli-def/blob/main/TODO.md
|
|
169
|
+
|
|
170
|
+
## 🤝 Contributing
|
|
171
|
+
|
|
172
|
+
Contributions are welcome!
|
|
173
|
+
|
|
174
|
+
## 📄 License
|
|
175
|
+
|
|
176
|
+
MIT License
|
|
177
|
+
|
cli_def-0.1.1/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# cli-def
|
|
2
|
+
|
|
3
|
+
A declarative DSL for defining CLI structures with a unified runtime and REPL for argparse/click backends.
|
|
4
|
+
|
|
5
|
+
project page:
|
|
6
|
+
https://cli-def.tomesoft.net
|
|
7
|
+
|
|
8
|
+
source:
|
|
9
|
+
https://github.com/tomesoft/cli-def
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- Define CLI structure declaratively (TOML / Python models)
|
|
14
|
+
- Generate CLI implementations for:
|
|
15
|
+
- `argparse` (standard library, no dependencies)
|
|
16
|
+
- `click` (optional dependency)
|
|
17
|
+
- Separation of:
|
|
18
|
+
- CLI definition (DSL)
|
|
19
|
+
- Runtime implementation (builders)
|
|
20
|
+
- Built-in runtime system:
|
|
21
|
+
- Event model (`CliEvent`)
|
|
22
|
+
- Runner
|
|
23
|
+
- Dispatcher
|
|
24
|
+
- Entrypoint resolution (`module:function`)
|
|
25
|
+
- Result propagation
|
|
26
|
+
- Interactive REPL support
|
|
27
|
+
- CLI chaining (execute one CLI from another)
|
|
28
|
+
|
|
29
|
+
## 📦 Installation
|
|
30
|
+
|
|
31
|
+
Core (argparse only)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cli-def
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
With click support
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install cli-def[click]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🚀 Quick Example
|
|
44
|
+
|
|
45
|
+
```toml
|
|
46
|
+
[cli]
|
|
47
|
+
key = "Your CLI"
|
|
48
|
+
help = "Help of your CLI"
|
|
49
|
+
prompt = "yourcli> "
|
|
50
|
+
|
|
51
|
+
[cli.echo]
|
|
52
|
+
args = [{key="message", mult="+"}]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cli-def run example.toml -- echo hello world
|
|
57
|
+
|
|
58
|
+
[run] forwarding args: ['echo', 'hello', 'world'], no_ctx_propagate: False
|
|
59
|
+
=== fallback handler ===
|
|
60
|
+
PATH: ['Your CLI', 'echo']
|
|
61
|
+
PARAMS: {'message': ['hello', 'world']}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 🚀 Quick Start (Demo)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
cli-def demo beginner
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
beginner profile reads in beginner.toml (see GitHub repository for details)
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
Type 'help' to list commands, 'exit' to exit
|
|
74
|
+
demo[beginner]> echo a b c d
|
|
75
|
+
a b c d
|
|
76
|
+
|
|
77
|
+
-> out[0]
|
|
78
|
+
demo[beginner]> greet John --upper
|
|
79
|
+
HELLO, JOHN!
|
|
80
|
+
|
|
81
|
+
-> out[1]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Advanced demo:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
cli-def demo advanced
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
See profiles:
|
|
91
|
+
https://github.com/tomesoft/cli-def/tree/main/src/cli_def/demo/profiles
|
|
92
|
+
|
|
93
|
+
## 🖥 Interactive Mode (REPL)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
cli-def repl --file your_cli.toml
|
|
97
|
+
yourcli> help
|
|
98
|
+
yourcli> command arg1 --option value
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 🔁 Run Another CLI (CLI chaining)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
cli-def run example.toml -- command arg1 arg2
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- `--` separates cli-def arguments from the target CLI arguments
|
|
108
|
+
- Remaining arguments are forwarded to the next CLI
|
|
109
|
+
|
|
110
|
+
## 📚 Documentation
|
|
111
|
+
|
|
112
|
+
Full documentation and design details are available on GitHub:
|
|
113
|
+
|
|
114
|
+
https://github.com/tomesoft/cli-def
|
|
115
|
+
|
|
116
|
+
- DSL specification
|
|
117
|
+
- Architecture
|
|
118
|
+
- Examples
|
|
119
|
+
- Development notes
|
|
120
|
+
|
|
121
|
+
## 📌 Roadmap
|
|
122
|
+
|
|
123
|
+
See TODO.md on GitHub:
|
|
124
|
+
https://github.com/tomesoft/cli-def/blob/main/TODO.md
|
|
125
|
+
|
|
126
|
+
## 🤝 Contributing
|
|
127
|
+
|
|
128
|
+
Contributions are welcome!
|
|
129
|
+
|
|
130
|
+
## 📄 License
|
|
131
|
+
|
|
132
|
+
MIT License
|
|
133
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cli-def
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A declarative DSL for composable CLI applications with runtime and REPL
|
|
5
|
+
Author: Tomesoft
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Tomesoft
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to do so, subject to the
|
|
15
|
+
following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://cli-def.tomesoft.net
|
|
28
|
+
Project-URL: Repository, https://github.com/tomesoft/cli-def
|
|
29
|
+
Classifier: Programming Language :: Python :: 3
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.10
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: wcwidth
|
|
37
|
+
Provides-Extra: click
|
|
38
|
+
Requires-Dist: click>=8.0; extra == "click"
|
|
39
|
+
Provides-Extra: repl
|
|
40
|
+
Requires-Dist: prompt_toolkit; extra == "repl"
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: pytest; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# cli-def
|
|
46
|
+
|
|
47
|
+
A declarative DSL for defining CLI structures with a unified runtime and REPL for argparse/click backends.
|
|
48
|
+
|
|
49
|
+
project page:
|
|
50
|
+
https://cli-def.tomesoft.net
|
|
51
|
+
|
|
52
|
+
source:
|
|
53
|
+
https://github.com/tomesoft/cli-def
|
|
54
|
+
|
|
55
|
+
## ✨ Features
|
|
56
|
+
|
|
57
|
+
- Define CLI structure declaratively (TOML / Python models)
|
|
58
|
+
- Generate CLI implementations for:
|
|
59
|
+
- `argparse` (standard library, no dependencies)
|
|
60
|
+
- `click` (optional dependency)
|
|
61
|
+
- Separation of:
|
|
62
|
+
- CLI definition (DSL)
|
|
63
|
+
- Runtime implementation (builders)
|
|
64
|
+
- Built-in runtime system:
|
|
65
|
+
- Event model (`CliEvent`)
|
|
66
|
+
- Runner
|
|
67
|
+
- Dispatcher
|
|
68
|
+
- Entrypoint resolution (`module:function`)
|
|
69
|
+
- Result propagation
|
|
70
|
+
- Interactive REPL support
|
|
71
|
+
- CLI chaining (execute one CLI from another)
|
|
72
|
+
|
|
73
|
+
## 📦 Installation
|
|
74
|
+
|
|
75
|
+
Core (argparse only)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install cli-def
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
With click support
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install cli-def[click]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 🚀 Quick Example
|
|
88
|
+
|
|
89
|
+
```toml
|
|
90
|
+
[cli]
|
|
91
|
+
key = "Your CLI"
|
|
92
|
+
help = "Help of your CLI"
|
|
93
|
+
prompt = "yourcli> "
|
|
94
|
+
|
|
95
|
+
[cli.echo]
|
|
96
|
+
args = [{key="message", mult="+"}]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
cli-def run example.toml -- echo hello world
|
|
101
|
+
|
|
102
|
+
[run] forwarding args: ['echo', 'hello', 'world'], no_ctx_propagate: False
|
|
103
|
+
=== fallback handler ===
|
|
104
|
+
PATH: ['Your CLI', 'echo']
|
|
105
|
+
PARAMS: {'message': ['hello', 'world']}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 🚀 Quick Start (Demo)
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
cli-def demo beginner
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
beginner profile reads in beginner.toml (see GitHub repository for details)
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
Type 'help' to list commands, 'exit' to exit
|
|
118
|
+
demo[beginner]> echo a b c d
|
|
119
|
+
a b c d
|
|
120
|
+
|
|
121
|
+
-> out[0]
|
|
122
|
+
demo[beginner]> greet John --upper
|
|
123
|
+
HELLO, JOHN!
|
|
124
|
+
|
|
125
|
+
-> out[1]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Advanced demo:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
cli-def demo advanced
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See profiles:
|
|
135
|
+
https://github.com/tomesoft/cli-def/tree/main/src/cli_def/demo/profiles
|
|
136
|
+
|
|
137
|
+
## 🖥 Interactive Mode (REPL)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cli-def repl --file your_cli.toml
|
|
141
|
+
yourcli> help
|
|
142
|
+
yourcli> command arg1 --option value
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 🔁 Run Another CLI (CLI chaining)
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cli-def run example.toml -- command arg1 arg2
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- `--` separates cli-def arguments from the target CLI arguments
|
|
152
|
+
- Remaining arguments are forwarded to the next CLI
|
|
153
|
+
|
|
154
|
+
## 📚 Documentation
|
|
155
|
+
|
|
156
|
+
Full documentation and design details are available on GitHub:
|
|
157
|
+
|
|
158
|
+
https://github.com/tomesoft/cli-def
|
|
159
|
+
|
|
160
|
+
- DSL specification
|
|
161
|
+
- Architecture
|
|
162
|
+
- Examples
|
|
163
|
+
- Development notes
|
|
164
|
+
|
|
165
|
+
## 📌 Roadmap
|
|
166
|
+
|
|
167
|
+
See TODO.md on GitHub:
|
|
168
|
+
https://github.com/tomesoft/cli-def/blob/main/TODO.md
|
|
169
|
+
|
|
170
|
+
## 🤝 Contributing
|
|
171
|
+
|
|
172
|
+
Contributions are welcome!
|
|
173
|
+
|
|
174
|
+
## 📄 License
|
|
175
|
+
|
|
176
|
+
MIT License
|
|
177
|
+
|