Generate modern CLIs from OpenAPI specifications
Project description
CLI WIZARD
Generate modern CLIs from OpenAPI specifications.
Table of Contents
Features
Code Generation
- Generate complete Python CLI projects from OpenAPI v3 specifications
- Automatic command grouping based on OpenAPI tags
- Automatic help generation for all commands
- Clean, colored terminal output
--debugflag for verbose logging- Built-in API client with configurable base URL and timeout
- SSL/TLS support with custom CA certificate bundles
--ca-fileoption to specify custom CA certificates at runtime--no-verify-sslflag to disable certificate verification
Customization
- YAML-based configuration for full customization
- Configurable output directory and package name
- Tag inclusion/exclusion filters
- Custom command naming via
TagMappingandCommandMapping - Customizable splash screen with color support
- Configurable logging with colors, file output, and rotation
Developer Experience
- Generated projects are pip-installable out of the box
- Auto-generated
pyproject.toml,README.md, andVERSION - Resources (CA certs, splash files) bundled in the package
- Profile management for storing credentials and settings
Installation
pip install cli-wizard
Usage
Step 1: Prepare Your OpenAPI Specification
Ensure you have an OpenAPI v3 specification file (JSON or YAML format). For example, openapi.yaml:
openapi: 3.0.0
info:
title: My API
version: 1.0.0
paths:
/users:
get:
operationId: listUsers
summary: List all users
tags:
- Users
responses:
'200':
description: OK
Step 2: Create a Configuration File
Create a config.yaml file with your CLI settings. At minimum, you need PackageName and DefaultBaseUrl:
# Required parameters
PackageName: "my-cli"
DefaultBaseUrl: "https://api.example.com"
# Optional: customize the splash screen
SplashFile: "splash.txt"
SplashColor: "#00FFFF"
# Optional: filter which tags to include
IncludeTags:
- Users
- Products
Step 3: Generate the CLI
Run the generate command:
cli-wizard generate --openapi openapi.yaml --config config.yaml --output my-cli
This creates a complete Python CLI project in the my-cli directory.
Step 4: Install the Generated CLI
Navigate to the generated project and install it:
pip install -e my-cli
Step 5: Use Your CLI
Your CLI is now ready to use:
my-cli --help
my-cli users list-users
Configuration
Configuration uses a YAML file with PascalCase parameter names. You can reference other parameters with #[ParamName] syntax and environment variables with ${VAR} syntax.
Required Parameters
| Parameter | Description |
|---|---|
PackageName |
Python package name for the generated CLI |
DefaultBaseUrl |
Default API base URL |
Common Parameters
| Parameter | Default | Description |
|---|---|---|
OutputDir |
#[PackageName] |
Output directory for the generated CLI project |
MainDir |
${HOME}/.#[PackageName] |
Main directory for CLI data (config, cache, logs) |
ProfileFile |
#[MainDir]/profiles.yaml |
Path to profiles YAML file |
ExcludeTags |
[] |
Tags to exclude from generation |
IncludeTags |
[] |
Tags to include (empty means all) |
TagMapping |
{} |
Map OpenAPI tags to CLI command group names |
CommandMapping |
{} |
Customize command names (operationId → command name) |
SplashFile |
None |
Path to splash text file |
SplashColor |
#FFFFFF |
Color for splash text (hex code) |
Timeout |
30 |
Request timeout in seconds |
CaFile |
None |
CA certificate file for SSL verification |
Logging Parameters
| Parameter | Default | Description |
|---|---|---|
LogLevel |
INFO |
Default log level (DEBUG, INFO, WARNING, ERROR) |
LogFormat |
[%(levelname)s] %(asctime)s %(message)s |
Log message format |
LogFile |
None |
Path to log file (None means console only) |
LogRotationType |
days |
Log rotation type: size or days |
LogRotationDays |
30 |
Log rotation interval in days |
LogColorStyle |
level |
Color style: full or level |
See the examples directory for complete configuration examples.
Commands
cli-wizard generate
Generate a CLI from an OpenAPI specification and configuration file.
cli-wizard generate [OPTIONS]
Options:
--openapi, -o- Path to OpenAPI spec file (default:openapi.yaml)--config, -c- Path to config YAML file (default:config.yaml)--output, -d- Output directory for generated CLI (default:cli)--working-dir, -w- Working directory for resolving relative paths
Issues
Please report any issues or feature requests on the GitHub Issues page.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_wizard-1.0.0.tar.gz.
File metadata
- Download URL: cli_wizard-1.0.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c38e15cab929b96f5a5451a46ccb419ed736edfb031fb91e986078d8dbf052ec
|
|
| MD5 |
97a1fe7f87accd64ae6f0c7a9f121d6d
|
|
| BLAKE2b-256 |
ff76c0c8ceb791a24f0afd9642593f0e7bbd3c0c8f8e1617d612597f26423913
|
File details
Details for the file cli_wizard-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cli_wizard-1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bbbdd5dddde368f2cc87a1b8b86920dc6576465ca90b7c9f40177546b110a6d
|
|
| MD5 |
153850fd419d1ead9fa2ed252925aa1b
|
|
| BLAKE2b-256 |
322f18e0ac41e3713f2ec02aa6d2f93f9abfa9ed16ed4f744acf13486f9c089a
|