Skip to main content

usage-spec-typer

Generates usage spec for CLIs written with Typer.

Install

pip install usage-spec-typer

Usage

import typer
from typer_usage import generate

app = typer.Typer(help="My CLI tool")

@app.command()
def hello(name: str = typer.Argument(help="Your name")):
    """Say hello"""

@app.command()
def build(
    output: str = typer.Option("dist", help="Output directory"),
    verbose: bool = typer.Option(False, help="Enable verbose output"),
):
    """Build the project"""

print(generate(app, "mycli"))

API

generate(app, bin_name=None)

Generates a usage spec in KDL format from a Typer Typer app.

generate_kdl(app, bin_name=None)

Alias for generate().

generate_json(app, bin_name=None)

Generates a usage spec in JSON format.

convert_root(app, bin_name=None)

Converts a Typer Typer app to the Spec data structure.

Supported Features

Typer Feature Usage Spec Mapping
app.info.name / bin_name name / bin
app.info.help about
typer.Option() flag
typer.Argument() arg
typer.Option(..., help=) Flag help
typer.Argument(..., help=) Arg help
typer.Option(...) (ellipsis) flag required=#true
bool type options Boolean flag (no arg)
--flag/--no-flag negate
count=True count=#true
type=click.Choice() choices
default=... default
hidden=True hide=#true
envvar="..." env
app.add_typer() cmd (recursive)
Subcommand groups subcommand_required=#true
Single command app Treated as root-level
--install-completion / --show-completion Filtered out

License

MIT

Release files for usage-spec-typer 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usage-spec-typer 1.2.1
File Size Uploaded
usage_spec_typer-1.2.1.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for usage-spec-typer 1.2.1
File Interpreter ABI Platform
usage_spec_typer-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / usage_spec_typer-1.2.1.tar.gz

Download URL usage_spec_typer-1.2.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8ebf66f5835308ea5199b8d5f26a6fac77267f550eb69ab4167799828f8ab654
BLAKE2b-256 checksum
How to use checksums
e1ca1293f42ad68eada42ae6234be5b34a07f4fc0b43ec8f1032e3c63cd0e9f8
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_typer-1.2.1-py3-none-any.whl

Download URL usage_spec_typer-1.2.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4683b0ac37ed5e359336a16ad1f63fb710369f917ec1baad798bdcb0aa7593cf
BLAKE2b-256 checksum
How to use checksums
15d1c800362361f77da6a65d90d159e3157ba2fd8f2c3ccaeea399bf7ea79d1e
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 history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page