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
Release files for usage-spec-click 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| usage_spec_click-1.2.1.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usage_spec_click-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / usage_spec_click-1.2.1.tar.gz
| Download URL | usage_spec_click-1.2.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fa8697c9ced0e659782767bb7c9fc1580cec10eb8fc4e4d54ac0640b43c9405
|
|
BLAKE2b-256 checksum How to use checksums |
b6d110ebb9aaf73cde7382726f7dffd2c406818967f08d278287ed6d1da87ff8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / usage_spec_click-1.2.1-py3-none-any.whl
| Download URL | usage_spec_click-1.2.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b16e9d3a2c43dd0f827f65db68c088fd8d299dcdcd0b4cb24514b22587d0fc12
|
|
BLAKE2b-256 checksum How to use checksums |
d3c3c62fddb1d54c5895768000a0ea0793f08692278efab4432770a0e931601b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|