Skip to main content

Typer Cheatsheet Command

A pluggable cheatsheet command for your Typer applications to visualize their command tree structure.

This library provides a cheatsheet subcommand that you can easily integrate into any existing Typer application. It automatically inspects your Typer application and its subcommands/groups to generate a clear, tree-like representation, making it easier for users to understand available commands.

It traverses the command tree generated by Typer and can also emit a versioned JSON description with command parameters for agents and tooling.

Installation

You can install this library directly from GitHub using uv

uv add git+https://github.com/mgaitan/typer-cheatsheet-command.git

Demo

You can run the demo application included in this repository to see the cheatsheet command in action:

uvx typer-cheatsheet-command cheatsheet

This will output a tree structure of the demo (dummy) application's commands:

Typer Cheatsheet Command Tree

Integrating into your Typer application

To add the cheatsheet command to your own Typer application, simply import the register_cheatsheet_command function and call it with your typer.Typer instance.

First, ensure typer-cheatsheet-command is installed in your project's environment.

Then, in your main application file (e.g., main.py):

# main.py
import typer
from typer_cheatsheet_command.cheatsheet_command import register_cheatsheet_command

app = typer.Typer(name="MyCoolApp", help="A cool command-line application.")


@app.command()
def hello(name: str = "World"):
    """Say hello to someone."""
    print(f"Hello {name}!")


users_app = typer.Typer(help="Manage users.")


@users_app.command("create")
def create_user(username: str):
    """Creates a new user."""
    print(f"Creating user {username}")


app.add_typer(users_app, name="users")

# Register the cheatsheet command
register_cheatsheet_command(app)

if __name__ == "__main__":
    app()

Now, when you run your application, the cheatsheet command will be available:

uv run main.py cheatsheet

This would produce an output similar to:

╭─ Cheatsheet ───────────────────────────────────────────────────────────────╮
│ MyCoolApp                                                                  │
│ ├── hello: Say hello to someone.                                           │
│ ├── cheatsheet: Show the command tree structure of the application.        │
│ └── users: Manage users.                                                   │
│     └── create: Creates a new user.                                        │
╰────────────────────────────────────────────────────────────────────────────╯

By default, the command is registered as cheatsheet. If you want to use a different name for the subcommand, you can set it explicitly

register_cheatsheet_command(app, command_name="cheat")

The command description is configurable and may contain multiple lines:

register_cheatsheet_command(
    app,
    description="""Show every available command.

    Includes nested groups and their parameters.
    """,
)

JSON output

Use JSON when another program needs to discover commands, options, arguments, and nested groups:

uv run main.py cheatsheet --output json

Hidden commands are excluded by default. Pass --show-all to include them in either output format.

The same data is available from Python without registering a command:

from typer_cheatsheet_command import get_command_tree

command_tree = get_command_tree(app)

Download files

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

Source Distribution

typer_cheatsheet_command-0.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

typer_cheatsheet_command-0.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file typer_cheatsheet_command-0.2.0.tar.gz.

File metadata

  • Download URL: typer_cheatsheet_command-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typer_cheatsheet_command-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cff400e74f2fdc1952be2fa2fe43326cb7e8286a1ab60ad0a9d6a7c57b7f6d72
MD5 88449eca456732d67240e4b517d745fa
BLAKE2b-256 eb96ad4aee9853e2afe39fca56063b126f32eca9763564ab9fb4fe91fb98a513

See more details on using hashes here.

Provenance

The following attestation bundles were made for typer_cheatsheet_command-0.2.0.tar.gz:

Publisher: cd.yml on mgaitan/typer-cheatsheet-command

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file typer_cheatsheet_command-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: typer_cheatsheet_command-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typer_cheatsheet_command-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3dbc0b466e955cc920921fce441e49f476839d79359aaf61407cb0cb573a053d
MD5 5967eace8ebf0fa05e401df5efb648e8
BLAKE2b-256 1d34b06b9e6f6874a2155e6ea5455298e9d4f66617a6e0ef1999780027c708b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for typer_cheatsheet_command-0.2.0-py3-none-any.whl:

Publisher: cd.yml on mgaitan/typer-cheatsheet-command

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 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