Print help for all commands and subcommands for argparse applications
Project description
totalhelp
An implementation of the totalhelp PEP.
This module provides monolithic help output for Python argparse applications, including those with deeply nested subcommands.
Usage
Works best with python tools that use Argparse.
totalhelp llm
totalhelp pipx
Caveats
- Help text is not a standard parsable format, so discovery of command names may fail.
- Can surface problems with applications that have slow startup.
Features
- Monolithic Help: Generate a single help document for your entire CLI, including all subcommands.
- Multiple Formats: Output to plain text, Markdown, or self-contained HTML.
- Drop-in Integration: Add a --totalhelp flag to your existing ArgumentParser with a single function call. No subclassing required.
- Optional rich support: If totalhelp[rich] is installed, get beautifully formatted terminal output.
- External Tool Inspection: A best-effort mode to generate help for third-party CLIs you don't control.
- InstallationInstall the base package:
pip install .
To include optional rich formatting support:pip install .[rich]
Quick Start
Integrate it into your application in three steps.
- Build your parser as usual.
# my_cli.py
import argparse
def create_parser():
parser = argparse.ArgumentParser(description="A complex tool.")
subparsers = parser.add_subparsers(dest="command", title="Available Commands")
# Command 'remote'
remote_parser = subparsers.add_parser("remote", help="Manage remotes")
remote_subparsers = remote_parser.add_subparsers(dest="remote_command")
remote_add_parser = remote_subparsers.add_parser("add", help="Add a remote")
remote_add_parser.add_argument("name", help="Name of the remote")
remote_add_parser.add_argument("url", help="URL of the remote")
# Command 'log'
log_parser = subparsers.add_parser("log", help="Show commit logs")
log_parser.add_argument("--oneline", action="store_true", help="Show logs in a compact format")
return parser
- Add the --totalhelp flag.
# my_cli.py (continued)
import sys
import totalhelp
parser = create_parser()
# Add the flag. That's it.
totalhelp.add_totalhelp_flag(parser)
- Check for the flag after parsing arguments.
# my_cli.py (continued)
if __name__ == "__main__":
args = parser.parse_args()
# If --totalhelp was passed, generate and print the doc, then exit.
if getattr(args, "totalhelp", False):
doc = totalhelp.full_help_from_parser(
parser,
fmt=getattr(args, "format", "text")
)
totalhelp.print_output(
doc,
fmt=getattr(args, "format", "text"),
open_browser=getattr(args, "open", False)
)
sys.exit(0)
# --- Your normal CLI logic goes here ---
print(f"Normal execution with args: {args}")
Now you can run your app to see the monolithic help:
Get full help in the terminal
python my_cli.py --totalhelp
Generate a Markdown document
python my_cli.py --totalhelp --format md > DOCS.md
Generate and open an HTML file in your browser
python my_cli.py --totalhelp --format html --open
Project details
Release history Release notifications | RSS feed
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 totalhelp-0.1.1.tar.gz.
File metadata
- Download URL: totalhelp-0.1.1.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de0962427d1184d9ee930ee2da8145a78361a3f709c2adb6664ada7970be05ec
|
|
| MD5 |
b9584f784f52d46af9a8222af145be92
|
|
| BLAKE2b-256 |
825bc708580abcc1fb33f121fa2bf8037d83092b0fa186d0450ad296f437528a
|
Provenance
The following attestation bundles were made for totalhelp-0.1.1.tar.gz:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/totalhelp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
totalhelp-0.1.1.tar.gz -
Subject digest:
de0962427d1184d9ee930ee2da8145a78361a3f709c2adb6664ada7970be05ec - Sigstore transparency entry: 583895646
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/totalhelp@ccf6d3b9e9cd62e48db150503c1d50ee2a5a246c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@ccf6d3b9e9cd62e48db150503c1d50ee2a5a246c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file totalhelp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: totalhelp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11e58377d5f7787d891aa2955146a74d30e7d40a3693e8dc8d2faab0b8da70a2
|
|
| MD5 |
fb935ae1f7b86126d0d114c0e5ef8f20
|
|
| BLAKE2b-256 |
fe614f00f9e035041b6a66fec4f07b6e3c03e65472a37bf77dfd0d35957041c7
|
Provenance
The following attestation bundles were made for totalhelp-0.1.1-py3-none-any.whl:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/totalhelp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
totalhelp-0.1.1-py3-none-any.whl -
Subject digest:
11e58377d5f7787d891aa2955146a74d30e7d40a3693e8dc8d2faab0b8da70a2 - Sigstore transparency entry: 583895648
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/totalhelp@ccf6d3b9e9cd62e48db150503c1d50ee2a5a246c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@ccf6d3b9e9cd62e48db150503c1d50ee2a5a246c -
Trigger Event:
workflow_dispatch
-
Statement type: