argparse-color-formatter


Nameargparse-color-formatter JSON
Version 2.0.0.post1 PyPI version JSON
download
home_page
SummaryA `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.
upload_time2024-03-18 14:55:22
maintainer
docs_urlNone
author
requires_python>=3.5
licenseBSD 3-Clause License Copyright (c) 2017, Emergence by Design Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords
VCS
bugtrack_url
requirements ansicolors
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # argparse-color-formatter
A [`formatter_class` for `argparse`](https://docs.python.org/3/library/argparse.html#formatter-class) 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...](https://docs.arrai.dev/argparse-color-formatter/readme/acf.png "That script's help text is so cool...")

[![PYPI](https://img.shields.io/pypi/v/argparse-color-formatter?style=for-the-badge)](https://pypi.org/project/argparse-color-formatter/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python312.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python312.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python312/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python311.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python311.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python311/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python310.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python310.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python310/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python39.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python39.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python39/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python38.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python38.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python38/)

![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python37.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python37.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python37/)

![Flake8](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/flake8.svg)

## Install

```shell
$ pip install argparse-color-formatter
```

## Usage

Pass in `argparse_color_formatter.ColorHelpFormatter` to a new argument parser as `formatter_class`

```python
import argparse
from argparse_color_formatter import ColorHelpFormatter

parser = argparse.ArgumentParser(
    formatter_class=ColorHelpFormatter
)
```

## Development

### Setup

```shell
pipenv install --dev
pre-commit install
pre-commit install --hook-type commit-msg
```

### Build

```shell
pipenv run build
```

### Test

```shell
pipenv run test
```

## After & Before
ANSI colour escapes using this library's new `ColorHelpFormatter`:
![after screenshot](https://docs.arrai.dev/argparse-color-formatter/readme/after.png)

ANSI colour escapes using the default `HelpFormatter`:
![before screenshot](https://docs.arrai.dev/argparse-color-formatter/readme/before.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "argparse-color-formatter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Arrai Innovations <support@arrai.com>",
    "download_url": "",
    "platform": null,
    "description": "# argparse-color-formatter\nA [`formatter_class` for `argparse`](https://docs.python.org/3/library/argparse.html#formatter-class) 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.\n\n![That script's help text is so cool...](https://docs.arrai.dev/argparse-color-formatter/readme/acf.png \"That script's help text is so cool...\")\n\n[![PYPI](https://img.shields.io/pypi/v/argparse-color-formatter?style=for-the-badge)](https://pypi.org/project/argparse-color-formatter/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python312.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python312.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python312/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python311.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python311.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python311/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python310.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python310.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python310/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python39.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python39.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python39/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python38.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python38.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python38/)\n\n![Tests](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python37.svg) [![Coverage](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/python37.coverage.svg)](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/htmlcov_python37/)\n\n![Flake8](https://docs.arrai.dev/argparse-color-formatter/artifacts/main/flake8.svg)\n\n## Install\n\n```shell\n$ pip install argparse-color-formatter\n```\n\n## Usage\n\nPass in `argparse_color_formatter.ColorHelpFormatter` to a new argument parser as `formatter_class`\n\n```python\nimport argparse\nfrom argparse_color_formatter import ColorHelpFormatter\n\nparser = argparse.ArgumentParser(\n    formatter_class=ColorHelpFormatter\n)\n```\n\n## Development\n\n### Setup\n\n```shell\npipenv install --dev\npre-commit install\npre-commit install --hook-type commit-msg\n```\n\n### Build\n\n```shell\npipenv run build\n```\n\n### Test\n\n```shell\npipenv run test\n```\n\n## After & Before\nANSI colour escapes using this library's new `ColorHelpFormatter`:\n![after screenshot](https://docs.arrai.dev/argparse-color-formatter/readme/after.png)\n\nANSI colour escapes using the default `HelpFormatter`:\n![before screenshot](https://docs.arrai.dev/argparse-color-formatter/readme/before.png)\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2017, Emergence by Design Inc. All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "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.",
    "version": "2.0.0.post1",
    "project_urls": {
        "repository": "https://github.com/arrai-innovations/argparse-color-formatter/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87fc1212fade6e562b903de597bc2f3e705cb4907c2f65cc5465c22ce7223c21",
                "md5": "41d7e7a6b3513abad968a53200648739",
                "sha256": "c7b0f94d8fe04deb3935f82eb58ba0f5b4c5254dbd8d4bca35cb9b39819e0374"
            },
            "downloads": -1,
            "filename": "argparse_color_formatter-2.0.0.post1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "41d7e7a6b3513abad968a53200648739",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.5",
            "size": 8057,
            "upload_time": "2024-03-18T14:55:22",
            "upload_time_iso_8601": "2024-03-18T14:55:22.353131Z",
            "url": "https://files.pythonhosted.org/packages/87/fc/1212fade6e562b903de597bc2f3e705cb4907c2f65cc5465c22ce7223c21/argparse_color_formatter-2.0.0.post1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-18 14:55:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arrai-innovations",
    "github_project": "argparse-color-formatter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [
        {
            "name": "ansicolors",
            "specs": [
                [
                    ">=",
                    "1.1.8"
                ],
                [
                    "<",
                    "2.0.0"
                ]
            ]
        }
    ],
    "lcname": "argparse-color-formatter"
}
        
Elapsed time: 0.19821s