reverse-argparse


Namereverse-argparse JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://github.com/sandialabs/reverse_argparse
SummaryGenerate the effective command line invocation for a script.
upload_time2024-05-13 13:50:22
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
            ![Lines of code](https://sloc.xyz/github/sandialabs/reverse_argparse/?category=code)
[![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/43/fe/c7b812ca38d2e45ac33e169eed28ff2ac46af3bd6f442a098d05375a2089/reverse_argparse-1.0.8.tar.gz",
    "platform": null,
    "description": "![Lines of code](https://sloc.xyz/github/sandialabs/reverse_argparse/?category=code)\n[![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.8",
    "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": "cde775b331ef8f35cf06e2d0e1500e1d6162c2bbe79cf6b356fec9c8c3209c00",
                "md5": "c36e6e2c53ebb382765d52abee0ab6c5",
                "sha256": "003d4055534c5f459426a4302b203aa73d53a1e78ab6877a252cba0d09a6e843"
            },
            "downloads": -1,
            "filename": "reverse_argparse-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c36e6e2c53ebb382765d52abee0ab6c5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9643,
            "upload_time": "2024-05-13T13:50:20",
            "upload_time_iso_8601": "2024-05-13T13:50:20.205561Z",
            "url": "https://files.pythonhosted.org/packages/cd/e7/75b331ef8f35cf06e2d0e1500e1d6162c2bbe79cf6b356fec9c8c3209c00/reverse_argparse-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43fec7b812ca38d2e45ac33e169eed28ff2ac46af3bd6f442a098d05375a2089",
                "md5": "940f0c88ea33435d79b66f5937133d3e",
                "sha256": "b38cca398edfa464ffdc2c19ea8548d5a7348e5d865a2b84914f9ad5835839c6"
            },
            "downloads": -1,
            "filename": "reverse_argparse-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "940f0c88ea33435d79b66f5937133d3e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10435,
            "upload_time": "2024-05-13T13:50:22",
            "upload_time_iso_8601": "2024-05-13T13:50:22.656591Z",
            "url": "https://files.pythonhosted.org/packages/43/fe/c7b812ca38d2e45ac33e169eed28ff2ac46af3bd6f442a098d05375a2089/reverse_argparse-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 13:50:22",
    "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: 1.20901s