Skip to content

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

License

Notifications You must be signed in to change notification settings

arrai-innovations/argparse-color-formatter

Repository files navigation

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

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
)

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

ANSI colour escapes using the default HelpFormatter: before screenshot

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages