/argparse-color-formatter

a `formatter_class` for argparse that knows how to deal with color escapes.

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

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.

That script's help text is so cool...

PYPI

Tests Coverage

Tests Coverage

Tests Coverage

Tests Coverage

Tests Coverage

Tests Coverage

Tests Coverage

Flake8

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: before screenshot

ANSI colour escapes using this libraries new ColorHelpFormatter: after screenshot