Skip to main content

Automatically use rich-argparse with argparse command line tools

Project description

auto-rich-argparse

Automatically use rich-argparse help formatters with argparse command line tools.

Usage

Install auto-rich-argparse in the same environment as your command line tool.

Try it out with your favorite tool using uvx --with auto-rich-argparse <YOUR_FAVORITE_TOOL> --help

Tools installed with pipx

If your tool is installed with pipx, use the pipx inject command to add auto-rich-argparse to the tool's environment. For example, to use rich-argparse with pre-commit:

pipx inject pre-commit auto-rich-argparse

Tools installed with uv tool

If your tool is installed with uv tool, use the --with flag to install auto-rich-argparse:

uv tool install pre-commit --with auto-rich-argparse

Tools in the current project

You can also install auto-rich-argparse in you project's environment and it will be used by all tools that use argparse in that environment:

python -m pip install auto-rich-argparse

How it works

auto-rich-argparse works by monkey patching the argparse.ArgumentParser class to use a subclass of RichHelpFormatter from rich-argparse instead of the default argparse.HelpFormatter. The formatter tries to be compatible with the tool's formatter by setting the following options:

FormatterClass.help_markup = False
FormatterClass.text_markup = False
FormatterClass.group_name_formatter = str

Known limitations

This doesn't currently work if the tool passes a function as the formatter_class argument to ArgumentParser instead of a class.

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

auto_rich_argparse-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

auto_rich_argparse-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file auto_rich_argparse-0.1.0.tar.gz.

File metadata

  • Download URL: auto_rich_argparse-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for auto_rich_argparse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 59b22a13f4a6f1d203078def3fe84fef04ae593ac5e577cc6edcdb2508fcb162
MD5 123a18dafb5015876ec4c17e790ea362
BLAKE2b-256 aab546540972601586d6eda8fef61af789497f5d5a55936078c9d2e1810cb1cd

See more details on using hashes here.

File details

Details for the file auto_rich_argparse-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_rich_argparse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b3ba3555078d6f762bfe1fc3a0648f95b3da7dea2727f81404b2085ff489d75
MD5 42567c9682bd03dc374c2e527e2a47f8
BLAKE2b-256 31021577e15742fee2e54c2c2b8859f5806238b105fe07c152f10361b8500f6e

See more details on using hashes here.

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