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:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff400e74f2fdc1952be2fa2fe43326cb7e8286a1ab60ad0a9d6a7c57b7f6d72
|
|
| MD5 |
88449eca456732d67240e4b517d745fa
|
|
| BLAKE2b-256 |
eb96ad4aee9853e2afe39fca56063b126f32eca9763564ab9fb4fe91fb98a513
|
Provenance
The following attestation bundles were made for typer_cheatsheet_command-0.2.0.tar.gz:
Publisher:
cd.yml on mgaitan/typer-cheatsheet-command
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typer_cheatsheet_command-0.2.0.tar.gz -
Subject digest:
cff400e74f2fdc1952be2fa2fe43326cb7e8286a1ab60ad0a9d6a7c57b7f6d72 - Sigstore transparency entry: 2618679045
- Sigstore integration time:
-
Permalink:
mgaitan/typer-cheatsheet-command@dc95a90e91ca33483a9348c43fd220fa1c979f08 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mgaitan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@dc95a90e91ca33483a9348c43fd220fa1c979f08 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dbc0b466e955cc920921fce441e49f476839d79359aaf61407cb0cb573a053d
|
|
| MD5 |
5967eace8ebf0fa05e401df5efb648e8
|
|
| BLAKE2b-256 |
1d34b06b9e6f6874a2155e6ea5455298e9d4f66617a6e0ef1999780027c708b6
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typer_cheatsheet_command-0.2.0-py3-none-any.whl -
Subject digest:
3dbc0b466e955cc920921fce441e49f476839d79359aaf61407cb0cb573a053d - Sigstore transparency entry: 2618679105
- Sigstore integration time:
-
Permalink:
mgaitan/typer-cheatsheet-command@dc95a90e91ca33483a9348c43fd220fa1c979f08 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mgaitan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@dc95a90e91ca33483a9348c43fd220fa1c979f08 -
Trigger Event:
release
-
Statement type: