Skip to main content

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

argparse_color_formatter-2.0.0-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file argparse_color_formatter-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_color_formatter-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 091255610c0929031d3376939bb7bdce88059326cf902bad73a46902da79163d
MD5 6d4aebe51360d9aaa61a1fee34a7bc90
BLAKE2b-256 45c8c2a664705da359ea3178be073fb580129d563fc3c7aaa231b9419942ce6e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page