Skip to main content

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


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.0.0.tar.gz (7.2 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.0.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: usage_spec_click-1.0.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.14

File hashes

Hashes for usage_spec_click-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f0dba231d152bdc0473c6c24772fdd011cfafcd2e653112acfea1592fa400ab0
MD5 40f810c2bab20fa28f9d74f6b5233dbd
BLAKE2b-256 13c41d1128892b091e0d4901cc3ec9fe88712009f6f37f839f55b78fdab9231c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for usage_spec_click-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7340f5d54a2fa476388eeaa7e051ca17b8fc798f65eef1fe255ebd2184891621
MD5 85c31ff516667d4a7cb44116bb0b4b0d
BLAKE2b-256 3cd8d5cbc76d076a50173348c8e75c89511a5385a5aef78c011c93eb8d48faab

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