reverse-argparse


Namereverse-argparse JSON
Version 1.0.7 PyPI version JSON
download
home_pagehttps://github.com/sandialabs/reverse_argparse
SummaryGenerate the effective command line invocation for a script.
upload_time2024-04-22 22:04:35
maintainerNone
docs_urlNone
authorJason M. Gates
requires_python>=3.8
licenseLICENSE.md
keywords argparse argument parse parsing command line
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            [![codecov](https://codecov.io/gh/sandialabs/reverse_argparse/branch/master/graph/badge.svg?token=FmDStZ6FVR)](https://codecov.io/gh/sandialabs/reverse_argparse)
[![CodeFactor](https://www.codefactor.io/repository/github/sandialabs/reverse_argparse/badge/master)](https://www.codefactor.io/repository/github/sandialabs/reverse_argparse/overview/master)
[![CodeQL](https://github.com/sandialabs/reverse_argparse/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/sandialabs/reverse_argparse/actions/workflows/github-code-scanning/codeql)
[![Conda Version](https://img.shields.io/conda/v/conda-forge/reverse-argparse?label=conda-forge)](https://anaconda.org/conda-forge/reverse-argparse)
![Conda Downloads](https://img.shields.io/conda/d/conda-forge/reverse-argparse?label=conda-forge%20downloads)
[![Continuous Integration](https://github.com/sandialabs/reverse_argparse/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/sandialabs/reverse_argparse/actions/workflows/continuous-integration.yml)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![GitHub contributors](https://img.shields.io/github/contributors/sandialabs/reverse_argparse.svg)](https://github.com/sandialabs/reverse_argparse/graphs/contributors)
[![Documentation Status](https://readthedocs.org/projects/reverse-argparse/badge/?version=latest)](https://reverse-argparse.readthedocs.io/en/latest/?badge=latest)
[![License](https://anaconda.org/conda-forge/reverse-argparse/badges/license.svg)](LICENSE.md)
[![Merged PRs](https://img.shields.io/github/issues-pr-closed-raw/sandialabs/reverse_argparse.svg?label=merged+PRs)](https://github.com/sandialabs/reverse_argparse/pulls?q=is:pr+is:merged)
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7632/badge)](https://bestpractices.coreinfrastructure.org/projects/7632)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sandialabs/reverse_argparse/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sandialabs/reverse_argparse)
![Platforms](https://anaconda.org/conda-forge/reverse-argparse/badges/platforms.svg)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/reverse_argparse/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/reverse_argparse/master)
[![PyPI - Version](https://img.shields.io/pypi/v/reverse-argparse?label=PyPI)](https://pypi.org/project/reverse-argparse/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/reverse-argparse?label=PyPI%20downloads)
![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

# reverse_argparse

Whereas [`argparse`][argparse] is concerned with taking a bunch of command line
arguments and parsing them, this package is intended to do the opposite; that
is, it'll take the parsed arguments and create the effective command line
invocation of the script that generated them.  The motivation is to be able to
tell users exactly what was used for all of the options, taking into
consideration any defaults and other transformations that might've been applied
in the midst of parsing, such that users are able to reproduce a prior run of a
script exactly.

[argparse]: https://docs.python.org/3/library/argparse.html

## Installation

To get up and running with `reverse_argparse`, simply:
```bash
python3 -m pip install reverse-argparse
```

## Usage

Once the package is installed, you can simply
```python
from argparse import ArgumentParser

from reverse_argparse import ReverseArgumentParser

# Parse the command line arguments.
parser = ArgumentParser()
# Build out the parser however you like.
args = parser.parse_args()
# Optionally post-process any `args`, as needed.

# Do whatever you need to in the script.

# Wrap things up.
print("This script executed the following:")
unparser = ReverseArgumentParser(parser, args)
print(unparser.get_pretty_command_line_invocation())
```

For more detailed usage and API information, please see
[our documentation][readthedocs].

[readthedocs]: https://reverse-argparse.readthedocs.io

## Where to Get Help

If you're having trouble with `reverse_argparse`, or just want to ask a
question, head on over to [our issue board][issues].  If a quick search doesn't
yield what you're looking for, feel free to file an issue.

[issues]: https://github.com/sandialabs/reverse_argparse/issues

## Contributing

If you're interested in contributing to the development of `reverse_argparse`,
we'd love to have your help :grinning:  Check out our
[contributing guidelines](CONTRIBUTING.md) for how to get started.
[Past contributors][contributors] include:
* [@jmgate](https://github.com/jmgate)

[contributors]: https://github.com/sandialabs/reverse_argparse/graphs/contributors

## License

See [LICENSE.md](LICENSE.md).

## Credits

Special thanks to [@mjsumpter][mjsumpter] for contributing to a prior iteration
of this concept, and to [the GMS project][gms] for investing in the development
of this package.

[mjsumpter]: https://github.com/mjsumpter
[gms]: https://github.com/SNL-GMS/GMS-PI25


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sandialabs/reverse_argparse",
    "name": "reverse-argparse",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "argparse, argument, parse, parsing, command line",
    "author": "Jason M. Gates",
    "author_email": "jmgate@sandia.gov",
    "download_url": "https://files.pythonhosted.org/packages/aa/71/2ff27c9413a7e71a17b7d002aafbf116e8c3bb8ed2c52a8231655a01c42a/reverse_argparse-1.0.7.tar.gz",
    "platform": null,
    "description": "[![codecov](https://codecov.io/gh/sandialabs/reverse_argparse/branch/master/graph/badge.svg?token=FmDStZ6FVR)](https://codecov.io/gh/sandialabs/reverse_argparse)\n[![CodeFactor](https://www.codefactor.io/repository/github/sandialabs/reverse_argparse/badge/master)](https://www.codefactor.io/repository/github/sandialabs/reverse_argparse/overview/master)\n[![CodeQL](https://github.com/sandialabs/reverse_argparse/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/sandialabs/reverse_argparse/actions/workflows/github-code-scanning/codeql)\n[![Conda Version](https://img.shields.io/conda/v/conda-forge/reverse-argparse?label=conda-forge)](https://anaconda.org/conda-forge/reverse-argparse)\n![Conda Downloads](https://img.shields.io/conda/d/conda-forge/reverse-argparse?label=conda-forge%20downloads)\n[![Continuous Integration](https://github.com/sandialabs/reverse_argparse/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/sandialabs/reverse_argparse/actions/workflows/continuous-integration.yml)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n[![GitHub contributors](https://img.shields.io/github/contributors/sandialabs/reverse_argparse.svg)](https://github.com/sandialabs/reverse_argparse/graphs/contributors)\n[![Documentation Status](https://readthedocs.org/projects/reverse-argparse/badge/?version=latest)](https://reverse-argparse.readthedocs.io/en/latest/?badge=latest)\n[![License](https://anaconda.org/conda-forge/reverse-argparse/badges/license.svg)](LICENSE.md)\n[![Merged PRs](https://img.shields.io/github/issues-pr-closed-raw/sandialabs/reverse_argparse.svg?label=merged+PRs)](https://github.com/sandialabs/reverse_argparse/pulls?q=is:pr+is:merged)\n[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7632/badge)](https://bestpractices.coreinfrastructure.org/projects/7632)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sandialabs/reverse_argparse/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sandialabs/reverse_argparse)\n![Platforms](https://anaconda.org/conda-forge/reverse-argparse/badges/platforms.svg)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/reverse_argparse/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/reverse_argparse/master)\n[![PyPI - Version](https://img.shields.io/pypi/v/reverse-argparse?label=PyPI)](https://pypi.org/project/reverse-argparse/)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/reverse-argparse?label=PyPI%20downloads)\n![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n# reverse_argparse\n\nWhereas [`argparse`][argparse] is concerned with taking a bunch of command line\narguments and parsing them, this package is intended to do the opposite; that\nis, it'll take the parsed arguments and create the effective command line\ninvocation of the script that generated them.  The motivation is to be able to\ntell users exactly what was used for all of the options, taking into\nconsideration any defaults and other transformations that might've been applied\nin the midst of parsing, such that users are able to reproduce a prior run of a\nscript exactly.\n\n[argparse]: https://docs.python.org/3/library/argparse.html\n\n## Installation\n\nTo get up and running with `reverse_argparse`, simply:\n```bash\npython3 -m pip install reverse-argparse\n```\n\n## Usage\n\nOnce the package is installed, you can simply\n```python\nfrom argparse import ArgumentParser\n\nfrom reverse_argparse import ReverseArgumentParser\n\n# Parse the command line arguments.\nparser = ArgumentParser()\n# Build out the parser however you like.\nargs = parser.parse_args()\n# Optionally post-process any `args`, as needed.\n\n# Do whatever you need to in the script.\n\n# Wrap things up.\nprint(\"This script executed the following:\")\nunparser = ReverseArgumentParser(parser, args)\nprint(unparser.get_pretty_command_line_invocation())\n```\n\nFor more detailed usage and API information, please see\n[our documentation][readthedocs].\n\n[readthedocs]: https://reverse-argparse.readthedocs.io\n\n## Where to Get Help\n\nIf you're having trouble with `reverse_argparse`, or just want to ask a\nquestion, head on over to [our issue board][issues].  If a quick search doesn't\nyield what you're looking for, feel free to file an issue.\n\n[issues]: https://github.com/sandialabs/reverse_argparse/issues\n\n## Contributing\n\nIf you're interested in contributing to the development of `reverse_argparse`,\nwe'd love to have your help :grinning:  Check out our\n[contributing guidelines](CONTRIBUTING.md) for how to get started.\n[Past contributors][contributors] include:\n* [@jmgate](https://github.com/jmgate)\n\n[contributors]: https://github.com/sandialabs/reverse_argparse/graphs/contributors\n\n## License\n\nSee [LICENSE.md](LICENSE.md).\n\n## Credits\n\nSpecial thanks to [@mjsumpter][mjsumpter] for contributing to a prior iteration\nof this concept, and to [the GMS project][gms] for investing in the development\nof this package.\n\n[mjsumpter]: https://github.com/mjsumpter\n[gms]: https://github.com/SNL-GMS/GMS-PI25\n\n",
    "bugtrack_url": null,
    "license": "LICENSE.md",
    "summary": "Generate the effective command line invocation for a script.",
    "version": "1.0.7",
    "project_urls": {
        "CI": "https://github.com/sandialabs/reverse_argparse/actions",
        "Documentation": "https://reverse-argparse.readthedocs.io",
        "Homepage": "https://github.com/sandialabs/reverse_argparse",
        "Issues": "https://github.com/sandialabs/reverse_argparse/issues",
        "Repository": "https://github.com/sandialabs/reverse_argparse"
    },
    "split_keywords": [
        "argparse",
        " argument",
        " parse",
        " parsing",
        " command line"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29a5bb02ac34f3ef6b53d916acc28c038a63983a7a3a58e1e2fb5de13e35c655",
                "md5": "9b8188ef9a9005368f51a21049807c5a",
                "sha256": "b7ab85bae7948d2838e0e841245d865bca2f14101ad06783f988c74a78d1f891"
            },
            "downloads": -1,
            "filename": "reverse_argparse-1.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9b8188ef9a9005368f51a21049807c5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9433,
            "upload_time": "2024-04-22T22:04:33",
            "upload_time_iso_8601": "2024-04-22T22:04:33.885823Z",
            "url": "https://files.pythonhosted.org/packages/29/a5/bb02ac34f3ef6b53d916acc28c038a63983a7a3a58e1e2fb5de13e35c655/reverse_argparse-1.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa712ff27c9413a7e71a17b7d002aafbf116e8c3bb8ed2c52a8231655a01c42a",
                "md5": "44d5e009f8c074e3f012eb692502cea9",
                "sha256": "0075e810a5130b04c00797ba123a1dfa14cc90c61f322b370ba40e36b3fe9685"
            },
            "downloads": -1,
            "filename": "reverse_argparse-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "44d5e009f8c074e3f012eb692502cea9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10494,
            "upload_time": "2024-04-22T22:04:35",
            "upload_time_iso_8601": "2024-04-22T22:04:35.627542Z",
            "url": "https://files.pythonhosted.org/packages/aa/71/2ff27c9413a7e71a17b7d002aafbf116e8c3bb8ed2c52a8231655a01c42a/reverse_argparse-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-22 22:04:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sandialabs",
    "github_project": "reverse_argparse",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "reverse-argparse"
}
        
Elapsed time: 0.28183s