Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usage_spec_click-1.2.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usage_spec_click-1.2.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file usage_spec_click-1.2.1.tar.gz.

File metadata

  • Download URL: usage_spec_click-1.2.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for usage_spec_click-1.2.1.tar.gz
Algorithm Hash digest
SHA256 8fa8697c9ced0e659782767bb7c9fc1580cec10eb8fc4e4d54ac0640b43c9405
MD5 47a30b7f751dd150df1662b9fa924411
BLAKE2b-256 b6d110ebb9aaf73cde7382726f7dffd2c406818967f08d278287ed6d1da87ff8

See more details on using hashes here.

File details

Details for the file usage_spec_click-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: usage_spec_click-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for usage_spec_click-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b16e9d3a2c43dd0f827f65db68c088fd8d299dcdcd0b4cb24514b22587d0fc12
MD5 e7ee966371d36d7f7661efea3f756bf5
BLAKE2b-256 d3c3c62fddb1d54c5895768000a0ea0793f08692278efab4432770a0e931601b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page