A `formatter_class` for `argparse` that deals with ANSI colour escapes. Specifically, this formatter does not count escape characters as displayed characters when wrapping `argparse`'s help text into the terminal.
Project description
argparse-color-formatter
A formatter_class for argparse that deals with ANSI colour escapes. Specifically, this formatter does not count escape characters as displayed characters when wrapping argparse's help text into the terminal.
Install
$ pip install argparse-color-formatter
Usage
Pass in argparse_color_formatter.ColorHelpFormatter to a new argument parser as formatter_class
import argparse
from argparse_color_formatter import ColorHelpFormatter
parser = argparse.ArgumentParser(
formatter_class=ColorHelpFormatter
)
Development
Setup
pipenv install --dev
pre-commit install
pre-commit install --hook-type commit-msg
Build
pipenv run build
Test
pipenv run test
After & Before
ANSI colour escapes using this library's new ColorHelpFormatter:
ANSI colour escapes using the default HelpFormatter:
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 Distributions
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 argparse_color_formatter-2.0.0.post1-py2.py3-none-any.whl.
File metadata
- Download URL: argparse_color_formatter-2.0.0.post1-py2.py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7b0f94d8fe04deb3935f82eb58ba0f5b4c5254dbd8d4bca35cb9b39819e0374
|
|
| MD5 |
41d7e7a6b3513abad968a53200648739
|
|
| BLAKE2b-256 |
87fc1212fade6e562b903de597bc2f3e705cb4907c2f65cc5465c22ce7223c21
|