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.2.0.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.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for usage_spec_click-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ecd9132005f61c7b5b1a5ac52277892a42a014b012f8c3f83ab96ee0db9cb9ca
MD5 670b16fc29fbbd3e6ee434b031a41c48
BLAKE2b-256 43f1f0f35bcdebd21ab340f192c71a659d3d1025159e34f40db9666d48b51957

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for usage_spec_click-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e4204afbdf08450ee826e3dd4604eac6d7d2a23334d0f7987b531129b39f01d
MD5 6c2b7387e7f7be18d540be5ae6052c43
BLAKE2b-256 a0fabd7ea34d455345d00fb9304b2e0b10aa6f2d0a6bc6ccd12d1f2dd963946e

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