Generates usage spec for CLIs written with click
Project description
usage-spec-click
Generates usage spec for CLIs written with click.
Install
pip install usage-spec-click
Usage
import click
from click_usage import generate
@click.command()
@click.version_option("1.0.0")
@click.option("-v", "--verbose", is_flag=True, help="Enable verbose output")
@click.option("-f", "--file", type=str, help="Input file")
@click.option("--color/--no-color", default=False, help="Color output")
def cli(verbose, file, color):
pass
print(generate(cli, "mycli"))
API
generate(cmd, bin_name=None)
Generates a usage spec in KDL format from a click Command or Group.
generate_kdl(cmd, bin_name=None)
Alias for generate().
generate_json(cmd, bin_name=None)
Generates a usage spec in JSON format.
convert_root(cmd, bin_name=None)
Converts a click Command or Group to the Spec data structure.
Supported Features
| click Feature | Usage Spec Mapping |
|---|---|
cmd.name |
name / bin |
@click.version_option() |
version |
cmd.short_help / cmd.help |
about / long_about |
@click.option() |
flag |
required=True |
flag required=#true |
is_flag=True |
Boolean flag (no arg) |
--flag/--no-flag |
negate |
count=True |
count=#true |
multiple=True |
var=#true |
type=click.Choice() |
choices |
default=... |
default |
hidden=True |
hide=#true |
deprecated="..." |
deprecated |
envvar="..." |
env |
@click.argument() |
arg |
@click.group() subcommands |
cmd (recursive) |
| Groups without positional args | subcommand_required=#true |
cmd.hidden |
Commands hidden from listing |
License
MIT
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 usage_spec_click-1.1.0.tar.gz.
File metadata
- Download URL: usage_spec_click-1.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d4c9a98a312a6a5c5d90ff4e6bcb793af1a61f604591681de93ab24abee41e2
|
|
| MD5 |
546bae36cd4f25a2480ad198acffdfa9
|
|
| BLAKE2b-256 |
26ddd9466a373f67d10195c80bd550af43b3fc397c7e3f6c0f4499cc831c3829
|
File details
Details for the file usage_spec_click-1.1.0-py3-none-any.whl.
File metadata
- Download URL: usage_spec_click-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46c057bf1b5310f04cb890e41fe8bc0eee5a3fdfe2e2431cc3043e0dd97166da
|
|
| MD5 |
ecf5401bf4c71e9339262d48ec42fc96
|
|
| BLAKE2b-256 |
de3e55aa773cdcebb8d77ccdc4fa39f9b118dc7b6a287fe8e532eee4fd34293c
|