Skip to main content

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.

  1. 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
  1. 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)
  1. 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


Download files

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

Source Distribution

totalhelp-0.1.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

totalhelp-0.1.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

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

Hashes for totalhelp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 de0962427d1184d9ee930ee2da8145a78361a3f709c2adb6664ada7970be05ec
MD5 b9584f784f52d46af9a8222af145be92
BLAKE2b-256 825bc708580abcc1fb33f121fa2bf8037d83092b0fa186d0450ad296f437528a

See more details on using hashes here.

Provenance

The following attestation bundles were made for totalhelp-0.1.1.tar.gz:

Publisher: publish_to_pypi.yml on matthewdeanmartin/totalhelp

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

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

Hashes for totalhelp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11e58377d5f7787d891aa2955146a74d30e7d40a3693e8dc8d2faab0b8da70a2
MD5 fb935ae1f7b86126d0d114c0e5ef8f20
BLAKE2b-256 fe614f00f9e035041b6a66fec4f07b6e3c03e65472a37bf77dfd0d35957041c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for totalhelp-0.1.1-py3-none-any.whl:

Publisher: publish_to_pypi.yml on matthewdeanmartin/totalhelp

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

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