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
)
Before & After
ANSI colour escapes using the default HelpFormatter
:
ANSI colour escapes using this libraries new ColorHelpFormatter
: