cli-wizard 1.0.0__py3-none-any.whl
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/__init__.py +4 -0
- cli_wizard/cli.py +37 -0
- cli_wizard/commands/__init__.py +4 -0
- cli_wizard/commands/common.py +36 -0
- cli_wizard/commands/config.py +82 -0
- cli_wizard/commands/generate.py +231 -0
- cli_wizard/config/__init__.py +0 -0
- cli_wizard/config/configuration.py +53 -0
- cli_wizard/config/default_config.yaml +7 -0
- cli_wizard/config/schema.py +182 -0
- cli_wizard/constants.py +11 -0
- cli_wizard/generator/__init__.py +22 -0
- cli_wizard/generator/generator.py +241 -0
- cli_wizard/generator/models.py +123 -0
- cli_wizard/generator/parser.py +171 -0
- cli_wizard/templates/README.md.j2 +31 -0
- cli_wizard/templates/cli.py.j2 +85 -0
- cli_wizard/templates/client.py.j2 +134 -0
- cli_wizard/templates/command_group.py.j2 +161 -0
- cli_wizard/templates/commands_config.py.j2 +206 -0
- cli_wizard/templates/commands_init.py.j2 +14 -0
- cli_wizard/templates/constants.py.j2 +67 -0
- cli_wizard/templates/logging.py.j2 +175 -0
- cli_wizard/templates/package_init.py.j2 +8 -0
- cli_wizard/templates/profile.py.j2 +87 -0
- cli_wizard/templates/pyproject.toml.j2 +28 -0
- cli_wizard-1.0.0.dist-info/METADATA +236 -0
- cli_wizard-1.0.0.dist-info/RECORD +32 -0
- cli_wizard-1.0.0.dist-info/WHEEL +5 -0
- cli_wizard-1.0.0.dist-info/entry_points.txt +2 -0
- cli_wizard-1.0.0.dist-info/licenses/LICENSE +21 -0
- cli_wizard-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from OpenAPI specification by cli-wizard
|
|
3
|
+
|
|
4
|
+
"""Logging utilities for the generated CLI."""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from datetime import datetime, timezone
|
|
8
|
+
from logging.handlers import RotatingFileHandler, TimedRotatingFileHandler
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
11
|
+
import click
|
|
12
|
+
|
|
13
|
+
from .constants import (
|
|
14
|
+
LOG_LEVEL,
|
|
15
|
+
LOG_FORMAT,
|
|
16
|
+
LOG_TIMESTAMP_FORMAT,
|
|
17
|
+
LOG_TIMEZONE,
|
|
18
|
+
LOG_COLOR_STYLE,
|
|
19
|
+
LOG_COLORS,
|
|
20
|
+
LOG_FILE,
|
|
21
|
+
LOG_ROTATION_TYPE,
|
|
22
|
+
LOG_ROTATION_SIZE_MB,
|
|
23
|
+
LOG_ROTATION_DAYS,
|
|
24
|
+
LOG_ROTATION_BACKUP_COUNT,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_file_handler = None
|
|
29
|
+
_debug_enabled = False
|
|
30
|
+
|
|
31
|
+
# Log level priorities
|
|
32
|
+
_LOG_LEVELS = {
|
|
33
|
+
"DEBUG": 10,
|
|
34
|
+
"INFO": 20,
|
|
35
|
+
"WARNING": 30,
|
|
36
|
+
"ERROR": 40,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def set_debug(enabled: bool) -> None:
|
|
41
|
+
"""Enable or disable debug logging."""
|
|
42
|
+
global _debug_enabled
|
|
43
|
+
_debug_enabled = enabled
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def is_debug_enabled() -> bool:
|
|
47
|
+
"""Check if debug logging is enabled."""
|
|
48
|
+
return _debug_enabled
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _should_log(level: str) -> bool:
|
|
52
|
+
"""Check if a message at the given level should be logged."""
|
|
53
|
+
if _debug_enabled:
|
|
54
|
+
return True
|
|
55
|
+
level_priority = _LOG_LEVELS.get(level, 20)
|
|
56
|
+
config_priority = _LOG_LEVELS.get(LOG_LEVEL, 20)
|
|
57
|
+
return level_priority >= config_priority
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
|
|
61
|
+
"""Convert hex color to RGB tuple."""
|
|
62
|
+
hex_color = hex_color.lstrip("#")
|
|
63
|
+
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _get_timestamp() -> str:
|
|
67
|
+
"""Get formatted timestamp based on configured timezone."""
|
|
68
|
+
if LOG_TIMEZONE == "UTC":
|
|
69
|
+
now = datetime.now(timezone.utc)
|
|
70
|
+
else:
|
|
71
|
+
now = datetime.now()
|
|
72
|
+
return now.strftime(LOG_TIMESTAMP_FORMAT)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _format_message(level: str, message: str) -> str:
|
|
76
|
+
"""Format log message according to LOG_FORMAT."""
|
|
77
|
+
timestamp = _get_timestamp()
|
|
78
|
+
# Replace Python logging format placeholders
|
|
79
|
+
formatted = LOG_FORMAT
|
|
80
|
+
formatted = formatted.replace("%(asctime)s", timestamp)
|
|
81
|
+
formatted = formatted.replace("%(levelname)s", level)
|
|
82
|
+
formatted = formatted.replace("%(message)s", message)
|
|
83
|
+
return formatted
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _get_file_handler():
|
|
87
|
+
"""Get or create the file handler for logging."""
|
|
88
|
+
global _file_handler
|
|
89
|
+
if _file_handler is not None:
|
|
90
|
+
return _file_handler
|
|
91
|
+
|
|
92
|
+
if LOG_FILE is None:
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
# Ensure log directory exists
|
|
96
|
+
LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
97
|
+
|
|
98
|
+
if LOG_ROTATION_TYPE == "size":
|
|
99
|
+
_file_handler = RotatingFileHandler(
|
|
100
|
+
LOG_FILE,
|
|
101
|
+
maxBytes=LOG_ROTATION_SIZE_MB * 1024 * 1024,
|
|
102
|
+
backupCount=LOG_ROTATION_BACKUP_COUNT,
|
|
103
|
+
)
|
|
104
|
+
else: # "days"
|
|
105
|
+
_file_handler = TimedRotatingFileHandler(
|
|
106
|
+
LOG_FILE,
|
|
107
|
+
when="D",
|
|
108
|
+
interval=LOG_ROTATION_DAYS,
|
|
109
|
+
backupCount=LOG_ROTATION_BACKUP_COUNT,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
return _file_handler
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _log_to_file(formatted_message: str) -> None:
|
|
116
|
+
"""Write log message to file if file logging is enabled."""
|
|
117
|
+
handler = _get_file_handler()
|
|
118
|
+
if handler is None:
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
with open(LOG_FILE, "a") as f:
|
|
123
|
+
f.write(formatted_message + "\n")
|
|
124
|
+
except (IOError, OSError):
|
|
125
|
+
pass # Silently ignore file write errors
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def log(level: Literal["DEBUG", "INFO", "WARNING", "ERROR"], message: str) -> None:
|
|
129
|
+
"""Log a message with the appropriate color based on level and style."""
|
|
130
|
+
if not _should_log(level):
|
|
131
|
+
return
|
|
132
|
+
|
|
133
|
+
color = LOG_COLORS.get(level, LOG_COLORS["INFO"])
|
|
134
|
+
rgb = _hex_to_rgb(color)
|
|
135
|
+
formatted = _format_message(level, message)
|
|
136
|
+
|
|
137
|
+
# Log to console with colors
|
|
138
|
+
if LOG_COLOR_STYLE == "full":
|
|
139
|
+
click.secho(formatted, fg=rgb, err=True)
|
|
140
|
+
else: # "level" style
|
|
141
|
+
# Find where the level appears in the formatted string and color only that part
|
|
142
|
+
level_start = formatted.find(level)
|
|
143
|
+
if level_start >= 0:
|
|
144
|
+
level_end = level_start + len(level)
|
|
145
|
+
before = formatted[:level_start]
|
|
146
|
+
after = formatted[level_end:]
|
|
147
|
+
click.echo(before, nl=False, err=True)
|
|
148
|
+
click.secho(level, fg=rgb, nl=False, err=True)
|
|
149
|
+
click.echo(after, err=True)
|
|
150
|
+
else:
|
|
151
|
+
# Fallback if level not found in format
|
|
152
|
+
click.echo(formatted, err=True)
|
|
153
|
+
|
|
154
|
+
# Log to file (without colors)
|
|
155
|
+
_log_to_file(formatted)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def log_debug(message: str) -> None:
|
|
159
|
+
"""Log a DEBUG message."""
|
|
160
|
+
log("DEBUG", message)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def log_info(message: str) -> None:
|
|
164
|
+
"""Log an INFO message."""
|
|
165
|
+
log("INFO", message)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def log_warning(message: str) -> None:
|
|
169
|
+
"""Log a WARNING message."""
|
|
170
|
+
log("WARNING", message)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def log_error(message: str) -> None:
|
|
174
|
+
"""Log an ERROR message."""
|
|
175
|
+
log("ERROR", message)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from OpenAPI specification by cli-wizard
|
|
3
|
+
|
|
4
|
+
"""Profile management for the generated CLI."""
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import yaml
|
|
10
|
+
|
|
11
|
+
from .constants import PROFILE_FILE
|
|
12
|
+
from .logging import log_error, log_info, log_warning, log_debug
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_current_profile: dict[str, Any] = {}
|
|
16
|
+
_profile_name: str = "default"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_profile(profile_name: str = "default") -> dict[str, Any]:
|
|
20
|
+
"""Load a profile from the profiles file.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
profile_name: Name of the profile to load (default: "default")
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
Profile settings as a dictionary, empty dict if profile not found
|
|
27
|
+
"""
|
|
28
|
+
global _current_profile, _profile_name
|
|
29
|
+
_profile_name = profile_name
|
|
30
|
+
|
|
31
|
+
if not PROFILE_FILE.exists():
|
|
32
|
+
log_warning(f"Profile file not found: {PROFILE_FILE}. Creating default profile file.")
|
|
33
|
+
_create_default_profile_file()
|
|
34
|
+
_current_profile = {}
|
|
35
|
+
return _current_profile
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
with open(PROFILE_FILE) as f:
|
|
39
|
+
profiles = yaml.safe_load(f) or {}
|
|
40
|
+
except (yaml.YAMLError, IOError) as e:
|
|
41
|
+
log_error(f"Failed to load profile file: {e}")
|
|
42
|
+
_current_profile = {}
|
|
43
|
+
return _current_profile
|
|
44
|
+
|
|
45
|
+
if profile_name not in profiles:
|
|
46
|
+
log_error(f"Profile '{profile_name}' not found in {PROFILE_FILE}")
|
|
47
|
+
_current_profile = {}
|
|
48
|
+
return _current_profile
|
|
49
|
+
|
|
50
|
+
_current_profile = profiles[profile_name] or {}
|
|
51
|
+
log_debug(f"Loaded profile '{profile_name}'")
|
|
52
|
+
return _current_profile
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _create_default_profile_file() -> None:
|
|
56
|
+
"""Create a default profile file with empty settings."""
|
|
57
|
+
try:
|
|
58
|
+
PROFILE_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
default_content = {"default": {}}
|
|
60
|
+
with open(PROFILE_FILE, "w") as f:
|
|
61
|
+
yaml.safe_dump(default_content, f, default_flow_style=False)
|
|
62
|
+
log_info(f"Created default profile file: {PROFILE_FILE}")
|
|
63
|
+
except (IOError, OSError) as e:
|
|
64
|
+
log_error(f"Failed to create default profile file: {e}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def get_profile() -> dict[str, Any]:
|
|
68
|
+
"""Get the currently loaded profile settings."""
|
|
69
|
+
return _current_profile
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def get_profile_name() -> str:
|
|
73
|
+
"""Get the name of the currently loaded profile."""
|
|
74
|
+
return _profile_name
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def get_profile_value(key: str, default: Any = None) -> Any:
|
|
78
|
+
"""Get a value from the current profile.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
key: The key to look up
|
|
82
|
+
default: Default value if key not found
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
The value from the profile, or default if not found
|
|
86
|
+
"""
|
|
87
|
+
return _current_profile.get(key, default)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "{{ cli_name }}"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "CLI generated by cli-wizard from OpenAPI specification"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"click~=8.1",
|
|
14
|
+
"requests~=2.32",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
{{ cli_name }} = "{{ package_name }}.cli:main"
|
|
19
|
+
|
|
20
|
+
[tool.setuptools.packages.find]
|
|
21
|
+
where = ["src"]
|
|
22
|
+
include = ["{{ package_name }}*"]
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.package-data]
|
|
25
|
+
{{ package_name }} = ["resources/*"]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.dynamic]
|
|
28
|
+
version = {file = "VERSION"}
|
|
@@ -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,32 @@
|
|
|
1
|
+
cli_wizard/__init__.py,sha256=qskrxaFes1oOTjDJCm_CgVthUSH07RVkTyYu4mG5iLs,122
|
|
2
|
+
cli_wizard/cli.py,sha256=dHEfgosX-SkQyl-uisq8CTQsNyiz9vBR2ignyFKAnis,1018
|
|
3
|
+
cli_wizard/constants.py,sha256=8AxDk6pQt14_Uae6f-EzqxI33ZsdLOkMSM_2pLJNJ-Y,268
|
|
4
|
+
cli_wizard/commands/__init__.py,sha256=07m9FKgWx4sp1-lG9UnEUhJ6eC1QxJZkuX8-zuPsqW8,112
|
|
5
|
+
cli_wizard/commands/common.py,sha256=8BRevgoGESTNZhl5ZdP5hlhYOIzeNY3KbJGJFzBep18,820
|
|
6
|
+
cli_wizard/commands/config.py,sha256=HuxjiSlq9saWopLhqidLoFSofiGfVGYkMTySubBm22k,1872
|
|
7
|
+
cli_wizard/commands/generate.py,sha256=hiVYH6BqJw1nUj8ZNyn-55pzxc41froGTJi8Ie-KIGM,8024
|
|
8
|
+
cli_wizard/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
cli_wizard/config/configuration.py,sha256=hBWjlVRuHNItLNliFdmsx7yk3Ryd-0MiqYBY26UVf0w,1568
|
|
10
|
+
cli_wizard/config/default_config.yaml,sha256=kPr4TL9-rFl_1ILJAlOlJPGwRVLFKFKV_Ud6aZJlvwo,299
|
|
11
|
+
cli_wizard/config/schema.py,sha256=RkB6wx8txirEWWdnxjecTOvQ_lwc6YCQ_YeB2wsPGk4,5556
|
|
12
|
+
cli_wizard/generator/__init__.py,sha256=r1RaMoxCyAkeJzX_xnSKcQqS46P14u0SvZlYSZXJ7N8,478
|
|
13
|
+
cli_wizard/generator/generator.py,sha256=aToUGXEL4_dRaxkAUjjemhgrW4Ub9Mntnh-NexoNbcA,8967
|
|
14
|
+
cli_wizard/generator/models.py,sha256=wjhoNe5nZlAOCrgHZn1rSPMQaDeIjGPXNyePNphYO9E,3353
|
|
15
|
+
cli_wizard/generator/parser.py,sha256=IEO-GGuf6PZC2wbZnLCrhgWpuBCiZfKmljnTp6H463w,6075
|
|
16
|
+
cli_wizard/templates/README.md.j2,sha256=32NU1X_uIGhc1YN8EoK1WP-3qGCAntzVyLqgpZzS8Ac,458
|
|
17
|
+
cli_wizard/templates/cli.py.j2,sha256=4bvcwktvRKu_kk06p2RPHjWDZwPbZS8uPLKhIKesi8w,2650
|
|
18
|
+
cli_wizard/templates/client.py.j2,sha256=lJ6_J5T_RNbpUUuY6SskvPsIojPgZYqgCxSZCMm9ze8,4626
|
|
19
|
+
cli_wizard/templates/command_group.py.j2,sha256=JLE3-mkF66LH8875AvbcL-rkUh33T3e-Y-hr5wPYc_0,6547
|
|
20
|
+
cli_wizard/templates/commands_config.py.j2,sha256=Vs7O6YeUvTyO_v49Y9cYuXeKYefJFUg0fISyTjYCoeI,7072
|
|
21
|
+
cli_wizard/templates/commands_init.py.j2,sha256=910j_k12juvJ81OBURe3fGwqI9ZaV7wVfa3_AVUVODc,332
|
|
22
|
+
cli_wizard/templates/constants.py.j2,sha256=ATdLlAPkcR5RsjJkq5I6jNAmAhQo8WpYDuJ1NYr7ddE,2337
|
|
23
|
+
cli_wizard/templates/logging.py.j2,sha256=1uGbhXHmYjgVgMF7DDd8nUPe6foCeOfs57LEQdMtsSU,4756
|
|
24
|
+
cli_wizard/templates/package_init.py.j2,sha256=e4InAuMzbMI_0c1qCEkhznkDEYpf35bp8F8XbIcbyCA,221
|
|
25
|
+
cli_wizard/templates/profile.py.j2,sha256=S3lvvvAvPp2sCbYtjIVDTQIXGusmxm6Wt9pJPLtdd7I,2599
|
|
26
|
+
cli_wizard/templates/pyproject.toml.j2,sha256=oMnP4_lpSmXJhWdD6ssQgKFGBz27JxpMtNvtqg9Upn8,630
|
|
27
|
+
cli_wizard-1.0.0.dist-info/licenses/LICENSE,sha256=QWDvpDLFr6usG-INpR6kp6T1cDedyofBzhfgGH5d_Tw,1073
|
|
28
|
+
cli_wizard-1.0.0.dist-info/METADATA,sha256=6bkBSyXWSZEcfnIxFWgUwFYHUi0jI-gNrPCOJx4HVe0,8098
|
|
29
|
+
cli_wizard-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
cli_wizard-1.0.0.dist-info/entry_points.txt,sha256=kkuya5VEYzjk6zS--OLHrh9nDb3sPfF5G37Bj5eEzgo,51
|
|
31
|
+
cli_wizard-1.0.0.dist-info/top_level.txt,sha256=-3mVQd20I8-Fd9cY0f7OUU1Dhv52bgOw9cuwOcKGOwI,11
|
|
32
|
+
cli_wizard-1.0.0.dist-info/RECORD,,
|
|
@@ -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 @@
|
|
|
1
|
+
cli_wizard
|