cli-wizard 1.0.0__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_wizard-1.0.0/LICENSE +21 -0
- cli_wizard-1.0.0/MANIFEST.in +5 -0
- cli_wizard-1.0.0/PKG-INFO +236 -0
- cli_wizard-1.0.0/README.md +193 -0
- cli_wizard-1.0.0/VERSION +1 -0
- cli_wizard-1.0.0/pyproject.toml +82 -0
- cli_wizard-1.0.0/setup.cfg +4 -0
- cli_wizard-1.0.0/src/cli_wizard/__init__.py +4 -0
- cli_wizard-1.0.0/src/cli_wizard/cli.py +37 -0
- cli_wizard-1.0.0/src/cli_wizard/commands/__init__.py +4 -0
- cli_wizard-1.0.0/src/cli_wizard/commands/common.py +36 -0
- cli_wizard-1.0.0/src/cli_wizard/commands/config.py +82 -0
- cli_wizard-1.0.0/src/cli_wizard/commands/generate.py +231 -0
- cli_wizard-1.0.0/src/cli_wizard/config/__init__.py +0 -0
- cli_wizard-1.0.0/src/cli_wizard/config/configuration.py +53 -0
- cli_wizard-1.0.0/src/cli_wizard/config/default_config.yaml +7 -0
- cli_wizard-1.0.0/src/cli_wizard/config/schema.py +182 -0
- cli_wizard-1.0.0/src/cli_wizard/constants.py +11 -0
- cli_wizard-1.0.0/src/cli_wizard/generator/__init__.py +22 -0
- cli_wizard-1.0.0/src/cli_wizard/generator/generator.py +241 -0
- cli_wizard-1.0.0/src/cli_wizard/generator/models.py +123 -0
- cli_wizard-1.0.0/src/cli_wizard/generator/parser.py +171 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/README.md.j2 +31 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/cli.py.j2 +85 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/client.py.j2 +134 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/command_group.py.j2 +161 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/commands_config.py.j2 +206 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/commands_init.py.j2 +14 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/constants.py.j2 +67 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/logging.py.j2 +175 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/package_init.py.j2 +8 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/profile.py.j2 +87 -0
- cli_wizard-1.0.0/src/cli_wizard/templates/pyproject.toml.j2 +28 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/PKG-INFO +236 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/SOURCES.txt +37 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/dependency_links.txt +1 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/entry_points.txt +2 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/requires.txt +24 -0
- cli_wizard-1.0.0/src/cli_wizard.egg-info/top_level.txt +1 -0
cli_wizard-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Giacomo Marciani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cli-wizard
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Generate modern CLIs from OpenAPI specifications
|
|
5
|
+
Author-email: Giacomo Marciani <giacomo.marciani@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gmarciani/cli-wizard
|
|
8
|
+
Project-URL: Repository, https://github.com/gmarciani/cli-wizard
|
|
9
|
+
Project-URL: Issues, https://github.com/gmarciani/cli-wizard/issues
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: click~=8.1
|
|
21
|
+
Requires-Dist: Jinja2~=3.1
|
|
22
|
+
Requires-Dist: pydantic~=2.10
|
|
23
|
+
Requires-Dist: PyYAML~=6.0
|
|
24
|
+
Requires-Dist: requests~=2.32
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: autoflake~=2.3; extra == "dev"
|
|
27
|
+
Requires-Dist: black~=26.1; extra == "dev"
|
|
28
|
+
Requires-Dist: build~=1.3; extra == "dev"
|
|
29
|
+
Requires-Dist: flake8~=7.3; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy~=1.18; extra == "dev"
|
|
31
|
+
Requires-Dist: pre-commit~=4.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest~=9.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov~=7.0; extra == "dev"
|
|
34
|
+
Requires-Dist: tox~=4.32; extra == "dev"
|
|
35
|
+
Requires-Dist: twine~=6.2; extra == "dev"
|
|
36
|
+
Requires-Dist: types-PyYAML~=6.0; extra == "dev"
|
|
37
|
+
Requires-Dist: types-requests~=2.32; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx~=9.1; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinx-click~=6.0; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinx-rtd-theme~=3.0; extra == "docs"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# CLI WIZARD
|
|
45
|
+
|
|
46
|
+
<div align="center">
|
|
47
|
+
<img src="https://raw.githubusercontent.com/gmarciani/cli-wizard/main/resources/brand/logo.png" alt="cli-wizard-logo" width="500">
|
|
48
|
+
|
|
49
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
50
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
51
|
+
[](https://github.com/gmarciani/cli-wizard/blob/main/LICENSE)
|
|
52
|
+
[](https://github.com/gmarciani/cli-wizard/actions)
|
|
53
|
+
[](https://github.com/gmarciani/cli-wizard/actions)
|
|
54
|
+
[](https://codecov.io/gh/gmarciani/cli-wizard)
|
|
55
|
+
[](https://github.com/psf/black)
|
|
56
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
Generate modern CLIs from OpenAPI specifications.
|
|
61
|
+
|
|
62
|
+
## Table of Contents
|
|
63
|
+
|
|
64
|
+
- [Features](#features)
|
|
65
|
+
- [Installation](#installation)
|
|
66
|
+
- [Usage](#usage)
|
|
67
|
+
- [Configuration](#configuration)
|
|
68
|
+
- [Commands](#commands)
|
|
69
|
+
- [Issues](#issues)
|
|
70
|
+
- [License](#license)
|
|
71
|
+
|
|
72
|
+
## Features
|
|
73
|
+
|
|
74
|
+
### Code Generation
|
|
75
|
+
- Generate complete Python CLI projects from OpenAPI v3 specifications
|
|
76
|
+
- Automatic command grouping based on OpenAPI tags
|
|
77
|
+
- Automatic help generation for all commands
|
|
78
|
+
- Clean, colored terminal output
|
|
79
|
+
- `--debug` flag for verbose logging
|
|
80
|
+
- Built-in API client with configurable base URL and timeout
|
|
81
|
+
- SSL/TLS support with custom CA certificate bundles
|
|
82
|
+
- `--ca-file` option to specify custom CA certificates at runtime
|
|
83
|
+
- `--no-verify-ssl` flag to disable certificate verification
|
|
84
|
+
|
|
85
|
+
### Customization
|
|
86
|
+
- YAML-based configuration for full customization
|
|
87
|
+
- Configurable output directory and package name
|
|
88
|
+
- Tag inclusion/exclusion filters
|
|
89
|
+
- Custom command naming via `TagMapping` and `CommandMapping`
|
|
90
|
+
- Customizable splash screen with color support
|
|
91
|
+
- Configurable logging with colors, file output, and rotation
|
|
92
|
+
|
|
93
|
+
### Developer Experience
|
|
94
|
+
- Generated projects are pip-installable out of the box
|
|
95
|
+
- Auto-generated `pyproject.toml`, `README.md`, and `VERSION`
|
|
96
|
+
- Resources (CA certs, splash files) bundled in the package
|
|
97
|
+
- Profile management for storing credentials and settings
|
|
98
|
+
|
|
99
|
+
## Installation
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
pip install cli-wizard
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
### Step 1: Prepare Your OpenAPI Specification
|
|
108
|
+
|
|
109
|
+
Ensure you have an OpenAPI v3 specification file (JSON or YAML format). For example, `openapi.yaml`:
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
openapi: 3.0.0
|
|
113
|
+
info:
|
|
114
|
+
title: My API
|
|
115
|
+
version: 1.0.0
|
|
116
|
+
paths:
|
|
117
|
+
/users:
|
|
118
|
+
get:
|
|
119
|
+
operationId: listUsers
|
|
120
|
+
summary: List all users
|
|
121
|
+
tags:
|
|
122
|
+
- Users
|
|
123
|
+
responses:
|
|
124
|
+
'200':
|
|
125
|
+
description: OK
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Step 2: Create a Configuration File
|
|
129
|
+
|
|
130
|
+
Create a `config.yaml` file with your CLI settings. At minimum, you need `PackageName` and `DefaultBaseUrl`:
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
# Required parameters
|
|
134
|
+
PackageName: "my-cli"
|
|
135
|
+
DefaultBaseUrl: "https://api.example.com"
|
|
136
|
+
|
|
137
|
+
# Optional: customize the splash screen
|
|
138
|
+
SplashFile: "splash.txt"
|
|
139
|
+
SplashColor: "#00FFFF"
|
|
140
|
+
|
|
141
|
+
# Optional: filter which tags to include
|
|
142
|
+
IncludeTags:
|
|
143
|
+
- Users
|
|
144
|
+
- Products
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Step 3: Generate the CLI
|
|
148
|
+
|
|
149
|
+
Run the `generate` command:
|
|
150
|
+
|
|
151
|
+
```shell
|
|
152
|
+
cli-wizard generate --openapi openapi.yaml --config config.yaml --output my-cli
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This creates a complete Python CLI project in the `my-cli` directory.
|
|
156
|
+
|
|
157
|
+
### Step 4: Install the Generated CLI
|
|
158
|
+
|
|
159
|
+
Navigate to the generated project and install it:
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
pip install -e my-cli
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 5: Use Your CLI
|
|
166
|
+
|
|
167
|
+
Your CLI is now ready to use:
|
|
168
|
+
|
|
169
|
+
```shell
|
|
170
|
+
my-cli --help
|
|
171
|
+
my-cli users list-users
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Configuration
|
|
175
|
+
|
|
176
|
+
Configuration uses a YAML file with PascalCase parameter names. You can reference other parameters with `#[ParamName]` syntax and environment variables with `${VAR}` syntax.
|
|
177
|
+
|
|
178
|
+
### Required Parameters
|
|
179
|
+
|
|
180
|
+
| Parameter | Description |
|
|
181
|
+
|-----------|-------------|
|
|
182
|
+
| `PackageName` | Python package name for the generated CLI |
|
|
183
|
+
| `DefaultBaseUrl` | Default API base URL |
|
|
184
|
+
|
|
185
|
+
### Common Parameters
|
|
186
|
+
|
|
187
|
+
| Parameter | Default | Description |
|
|
188
|
+
|-----------|---------|-------------|
|
|
189
|
+
| `OutputDir` | `#[PackageName]` | Output directory for the generated CLI project |
|
|
190
|
+
| `MainDir` | `${HOME}/.#[PackageName]` | Main directory for CLI data (config, cache, logs) |
|
|
191
|
+
| `ProfileFile` | `#[MainDir]/profiles.yaml` | Path to profiles YAML file |
|
|
192
|
+
| `ExcludeTags` | `[]` | Tags to exclude from generation |
|
|
193
|
+
| `IncludeTags` | `[]` | Tags to include (empty means all) |
|
|
194
|
+
| `TagMapping` | `{}` | Map OpenAPI tags to CLI command group names |
|
|
195
|
+
| `CommandMapping` | `{}` | Customize command names (operationId → command name) |
|
|
196
|
+
| `SplashFile` | `None` | Path to splash text file |
|
|
197
|
+
| `SplashColor` | `#FFFFFF` | Color for splash text (hex code) |
|
|
198
|
+
| `Timeout` | `30` | Request timeout in seconds |
|
|
199
|
+
| `CaFile` | `None` | CA certificate file for SSL verification |
|
|
200
|
+
|
|
201
|
+
### Logging Parameters
|
|
202
|
+
|
|
203
|
+
| Parameter | Default | Description |
|
|
204
|
+
|-----------|---------|-------------|
|
|
205
|
+
| `LogLevel` | `INFO` | Default log level (DEBUG, INFO, WARNING, ERROR) |
|
|
206
|
+
| `LogFormat` | `[%(levelname)s] %(asctime)s %(message)s` | Log message format |
|
|
207
|
+
| `LogFile` | `None` | Path to log file (None means console only) |
|
|
208
|
+
| `LogRotationType` | `days` | Log rotation type: `size` or `days` |
|
|
209
|
+
| `LogRotationDays` | `30` | Log rotation interval in days |
|
|
210
|
+
| `LogColorStyle` | `level` | Color style: `full` or `level` |
|
|
211
|
+
|
|
212
|
+
See the [examples](examples/) directory for complete configuration examples.
|
|
213
|
+
|
|
214
|
+
## Commands
|
|
215
|
+
|
|
216
|
+
### cli-wizard generate
|
|
217
|
+
|
|
218
|
+
Generate a CLI from an OpenAPI specification and configuration file.
|
|
219
|
+
|
|
220
|
+
```shell
|
|
221
|
+
cli-wizard generate [OPTIONS]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Options:
|
|
225
|
+
- `--openapi, -o` - Path to OpenAPI spec file (default: `openapi.yaml`)
|
|
226
|
+
- `--config, -c` - Path to config YAML file (default: `config.yaml`)
|
|
227
|
+
- `--output, -d` - Output directory for generated CLI (default: `cli`)
|
|
228
|
+
- `--working-dir, -w` - Working directory for resolving relative paths
|
|
229
|
+
|
|
230
|
+
## Issues
|
|
231
|
+
|
|
232
|
+
Please report any issues or feature requests on the [GitHub Issues](https://github.com/gmarciani/cli-wizard/issues) page.
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# CLI WIZARD
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/gmarciani/cli-wizard/main/resources/brand/logo.png" alt="cli-wizard-logo" width="500">
|
|
5
|
+
|
|
6
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
7
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
8
|
+
[](https://github.com/gmarciani/cli-wizard/blob/main/LICENSE)
|
|
9
|
+
[](https://github.com/gmarciani/cli-wizard/actions)
|
|
10
|
+
[](https://github.com/gmarciani/cli-wizard/actions)
|
|
11
|
+
[](https://codecov.io/gh/gmarciani/cli-wizard)
|
|
12
|
+
[](https://github.com/psf/black)
|
|
13
|
+
[](https://pypi.org/project/cli-wizard/)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
Generate modern CLIs from OpenAPI specifications.
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
|
|
21
|
+
- [Features](#features)
|
|
22
|
+
- [Installation](#installation)
|
|
23
|
+
- [Usage](#usage)
|
|
24
|
+
- [Configuration](#configuration)
|
|
25
|
+
- [Commands](#commands)
|
|
26
|
+
- [Issues](#issues)
|
|
27
|
+
- [License](#license)
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
### Code Generation
|
|
32
|
+
- Generate complete Python CLI projects from OpenAPI v3 specifications
|
|
33
|
+
- Automatic command grouping based on OpenAPI tags
|
|
34
|
+
- Automatic help generation for all commands
|
|
35
|
+
- Clean, colored terminal output
|
|
36
|
+
- `--debug` flag for verbose logging
|
|
37
|
+
- Built-in API client with configurable base URL and timeout
|
|
38
|
+
- SSL/TLS support with custom CA certificate bundles
|
|
39
|
+
- `--ca-file` option to specify custom CA certificates at runtime
|
|
40
|
+
- `--no-verify-ssl` flag to disable certificate verification
|
|
41
|
+
|
|
42
|
+
### Customization
|
|
43
|
+
- YAML-based configuration for full customization
|
|
44
|
+
- Configurable output directory and package name
|
|
45
|
+
- Tag inclusion/exclusion filters
|
|
46
|
+
- Custom command naming via `TagMapping` and `CommandMapping`
|
|
47
|
+
- Customizable splash screen with color support
|
|
48
|
+
- Configurable logging with colors, file output, and rotation
|
|
49
|
+
|
|
50
|
+
### Developer Experience
|
|
51
|
+
- Generated projects are pip-installable out of the box
|
|
52
|
+
- Auto-generated `pyproject.toml`, `README.md`, and `VERSION`
|
|
53
|
+
- Resources (CA certs, splash files) bundled in the package
|
|
54
|
+
- Profile management for storing credentials and settings
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
pip install cli-wizard
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Step 1: Prepare Your OpenAPI Specification
|
|
65
|
+
|
|
66
|
+
Ensure you have an OpenAPI v3 specification file (JSON or YAML format). For example, `openapi.yaml`:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
openapi: 3.0.0
|
|
70
|
+
info:
|
|
71
|
+
title: My API
|
|
72
|
+
version: 1.0.0
|
|
73
|
+
paths:
|
|
74
|
+
/users:
|
|
75
|
+
get:
|
|
76
|
+
operationId: listUsers
|
|
77
|
+
summary: List all users
|
|
78
|
+
tags:
|
|
79
|
+
- Users
|
|
80
|
+
responses:
|
|
81
|
+
'200':
|
|
82
|
+
description: OK
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 2: Create a Configuration File
|
|
86
|
+
|
|
87
|
+
Create a `config.yaml` file with your CLI settings. At minimum, you need `PackageName` and `DefaultBaseUrl`:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
# Required parameters
|
|
91
|
+
PackageName: "my-cli"
|
|
92
|
+
DefaultBaseUrl: "https://api.example.com"
|
|
93
|
+
|
|
94
|
+
# Optional: customize the splash screen
|
|
95
|
+
SplashFile: "splash.txt"
|
|
96
|
+
SplashColor: "#00FFFF"
|
|
97
|
+
|
|
98
|
+
# Optional: filter which tags to include
|
|
99
|
+
IncludeTags:
|
|
100
|
+
- Users
|
|
101
|
+
- Products
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Step 3: Generate the CLI
|
|
105
|
+
|
|
106
|
+
Run the `generate` command:
|
|
107
|
+
|
|
108
|
+
```shell
|
|
109
|
+
cli-wizard generate --openapi openapi.yaml --config config.yaml --output my-cli
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This creates a complete Python CLI project in the `my-cli` directory.
|
|
113
|
+
|
|
114
|
+
### Step 4: Install the Generated CLI
|
|
115
|
+
|
|
116
|
+
Navigate to the generated project and install it:
|
|
117
|
+
|
|
118
|
+
```shell
|
|
119
|
+
pip install -e my-cli
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Step 5: Use Your CLI
|
|
123
|
+
|
|
124
|
+
Your CLI is now ready to use:
|
|
125
|
+
|
|
126
|
+
```shell
|
|
127
|
+
my-cli --help
|
|
128
|
+
my-cli users list-users
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
Configuration uses a YAML file with PascalCase parameter names. You can reference other parameters with `#[ParamName]` syntax and environment variables with `${VAR}` syntax.
|
|
134
|
+
|
|
135
|
+
### Required Parameters
|
|
136
|
+
|
|
137
|
+
| Parameter | Description |
|
|
138
|
+
|-----------|-------------|
|
|
139
|
+
| `PackageName` | Python package name for the generated CLI |
|
|
140
|
+
| `DefaultBaseUrl` | Default API base URL |
|
|
141
|
+
|
|
142
|
+
### Common Parameters
|
|
143
|
+
|
|
144
|
+
| Parameter | Default | Description |
|
|
145
|
+
|-----------|---------|-------------|
|
|
146
|
+
| `OutputDir` | `#[PackageName]` | Output directory for the generated CLI project |
|
|
147
|
+
| `MainDir` | `${HOME}/.#[PackageName]` | Main directory for CLI data (config, cache, logs) |
|
|
148
|
+
| `ProfileFile` | `#[MainDir]/profiles.yaml` | Path to profiles YAML file |
|
|
149
|
+
| `ExcludeTags` | `[]` | Tags to exclude from generation |
|
|
150
|
+
| `IncludeTags` | `[]` | Tags to include (empty means all) |
|
|
151
|
+
| `TagMapping` | `{}` | Map OpenAPI tags to CLI command group names |
|
|
152
|
+
| `CommandMapping` | `{}` | Customize command names (operationId → command name) |
|
|
153
|
+
| `SplashFile` | `None` | Path to splash text file |
|
|
154
|
+
| `SplashColor` | `#FFFFFF` | Color for splash text (hex code) |
|
|
155
|
+
| `Timeout` | `30` | Request timeout in seconds |
|
|
156
|
+
| `CaFile` | `None` | CA certificate file for SSL verification |
|
|
157
|
+
|
|
158
|
+
### Logging Parameters
|
|
159
|
+
|
|
160
|
+
| Parameter | Default | Description |
|
|
161
|
+
|-----------|---------|-------------|
|
|
162
|
+
| `LogLevel` | `INFO` | Default log level (DEBUG, INFO, WARNING, ERROR) |
|
|
163
|
+
| `LogFormat` | `[%(levelname)s] %(asctime)s %(message)s` | Log message format |
|
|
164
|
+
| `LogFile` | `None` | Path to log file (None means console only) |
|
|
165
|
+
| `LogRotationType` | `days` | Log rotation type: `size` or `days` |
|
|
166
|
+
| `LogRotationDays` | `30` | Log rotation interval in days |
|
|
167
|
+
| `LogColorStyle` | `level` | Color style: `full` or `level` |
|
|
168
|
+
|
|
169
|
+
See the [examples](examples/) directory for complete configuration examples.
|
|
170
|
+
|
|
171
|
+
## Commands
|
|
172
|
+
|
|
173
|
+
### cli-wizard generate
|
|
174
|
+
|
|
175
|
+
Generate a CLI from an OpenAPI specification and configuration file.
|
|
176
|
+
|
|
177
|
+
```shell
|
|
178
|
+
cli-wizard generate [OPTIONS]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Options:
|
|
182
|
+
- `--openapi, -o` - Path to OpenAPI spec file (default: `openapi.yaml`)
|
|
183
|
+
- `--config, -c` - Path to config YAML file (default: `config.yaml`)
|
|
184
|
+
- `--output, -d` - Output directory for generated CLI (default: `cli`)
|
|
185
|
+
- `--working-dir, -w` - Working directory for resolving relative paths
|
|
186
|
+
|
|
187
|
+
## Issues
|
|
188
|
+
|
|
189
|
+
Please report any issues or feature requests on the [GitHub Issues](https://github.com/gmarciani/cli-wizard/issues) page.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
cli_wizard-1.0.0/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cli-wizard"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Generate modern CLIs from OpenAPI specifications"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Giacomo Marciani", email = "giacomo.marciani@gmail.com"}
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.12"
|
|
24
|
+
dependencies = [
|
|
25
|
+
"click~=8.1",
|
|
26
|
+
"Jinja2~=3.1",
|
|
27
|
+
"pydantic~=2.10",
|
|
28
|
+
"PyYAML~=6.0",
|
|
29
|
+
"requests~=2.32",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"autoflake~=2.3",
|
|
35
|
+
"black~=26.1",
|
|
36
|
+
"build~=1.3",
|
|
37
|
+
"flake8~=7.3",
|
|
38
|
+
"mypy~=1.18",
|
|
39
|
+
"pre-commit~=4.0",
|
|
40
|
+
"pytest~=9.0",
|
|
41
|
+
"pytest-cov~=7.0",
|
|
42
|
+
"tox~=4.32",
|
|
43
|
+
"twine~=6.2",
|
|
44
|
+
"types-PyYAML~=6.0",
|
|
45
|
+
"types-requests~=2.32",
|
|
46
|
+
]
|
|
47
|
+
docs = [
|
|
48
|
+
"sphinx~=9.1",
|
|
49
|
+
"sphinx-click~=6.0",
|
|
50
|
+
"sphinx-rtd-theme~=3.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
cli-wizard = "cli_wizard.cli:main"
|
|
55
|
+
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/gmarciani/cli-wizard"
|
|
58
|
+
Repository = "https://github.com/gmarciani/cli-wizard"
|
|
59
|
+
Issues = "https://github.com/gmarciani/cli-wizard/issues"
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
where = ["src"]
|
|
63
|
+
include = ["cli_wizard*"]
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.package-data]
|
|
66
|
+
cli_wizard = ["templates/*.j2", "config/*.yaml"]
|
|
67
|
+
|
|
68
|
+
[tool.setuptools.dynamic]
|
|
69
|
+
version = {file = "VERSION"}
|
|
70
|
+
|
|
71
|
+
[tool.black]
|
|
72
|
+
line-length = 88
|
|
73
|
+
target-version = ['py311']
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
python_version = "3.12"
|
|
77
|
+
warn_return_any = true
|
|
78
|
+
warn_unused_configs = true
|
|
79
|
+
disallow_untyped_defs = true
|
|
80
|
+
|
|
81
|
+
[tool.coverage.run]
|
|
82
|
+
omit = ["*/__init__.py"]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright (c) 2026, Giacomo Marciani
|
|
2
|
+
# Licensed under the MIT License
|
|
3
|
+
|
|
4
|
+
"""Main CLI module for CLI Wizard."""
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
import logging
|
|
8
|
+
from cli_wizard.constants import __version__
|
|
9
|
+
from cli_wizard.commands.config import config
|
|
10
|
+
from cli_wizard.commands.generate import generate
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.group()
|
|
14
|
+
@click.version_option(version=__version__, prog_name="cli-wizard")
|
|
15
|
+
@click.option("--debug", "-d", is_flag=True, help="Enable debug output")
|
|
16
|
+
@click.pass_context
|
|
17
|
+
def main(ctx: click.Context, debug: bool) -> None:
|
|
18
|
+
"""CLI Wizard - Generate modern CLI from OpenAPI."""
|
|
19
|
+
ctx.ensure_object(dict)
|
|
20
|
+
ctx.obj["debug"] = debug
|
|
21
|
+
|
|
22
|
+
# Configure logging
|
|
23
|
+
level = logging.DEBUG if debug else logging.INFO
|
|
24
|
+
logging.basicConfig(
|
|
25
|
+
level=level,
|
|
26
|
+
format="%(asctime)s %(levelname)s: %(message)s",
|
|
27
|
+
datefmt="%Y-%m-%dT%H:%M:%SZ",
|
|
28
|
+
)
|
|
29
|
+
logging.Formatter.converter = lambda *args: __import__("time").gmtime()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
main.add_command(config)
|
|
33
|
+
main.add_command(generate)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) 2026, Giacomo Marciani
|
|
2
|
+
# Licensed under the MIT License
|
|
3
|
+
|
|
4
|
+
"""Common utilities for CLI Wizard commands."""
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def configure_logging(debug: bool = False) -> None:
|
|
13
|
+
"""Configure logging with UTC timestamps.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
debug: Whether to enable debug level logging
|
|
17
|
+
"""
|
|
18
|
+
import time
|
|
19
|
+
|
|
20
|
+
for handler in logging.root.handlers[:]:
|
|
21
|
+
logging.root.removeHandler(handler)
|
|
22
|
+
level = logging.DEBUG if debug else logging.INFO
|
|
23
|
+
logging.basicConfig(
|
|
24
|
+
level=level,
|
|
25
|
+
format="%(asctime)s %(levelname)s: %(message)s",
|
|
26
|
+
datefmt="%Y-%m-%dT%H:%M:%SZ",
|
|
27
|
+
)
|
|
28
|
+
logging.Formatter.converter = time.gmtime
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
debug_option = click.option(
|
|
32
|
+
"--debug",
|
|
33
|
+
"-d",
|
|
34
|
+
is_flag=True,
|
|
35
|
+
help="Enable debug output",
|
|
36
|
+
)
|