Skip to main content

Generate the effective command line invocation for a script.

Project description

codecov CodeFactor CodeQL Conda Version Conda Downloads Continuous Integration Contributor Covenant GitHub contributors Documentation Status License Merged PRs OpenSSF Best Practices OpenSSF Scorecard Platforms pre-commit pre-commit.ci Status PyPI - Version PyPI - Downloads Python Version Ruff

reverse_argparse

Whereas 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.

Installation

To get up and running with reverse_argparse, simply:

python3 -m pip install reverse-argparse

Usage

Once the package is installed, you can simply

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.

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. If a quick search doesn't yield what you're looking for, feel free to file an issue.

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 for how to get started. Past contributors include:

License

See LICENSE.md.

Credits

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

Project details


Download files

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

Source Distribution

reverse_argparse-1.0.7.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reverse_argparse-1.0.7-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file reverse_argparse-1.0.7.tar.gz.

File metadata

  • Download URL: reverse_argparse-1.0.7.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for reverse_argparse-1.0.7.tar.gz
Algorithm Hash digest
SHA256 0075e810a5130b04c00797ba123a1dfa14cc90c61f322b370ba40e36b3fe9685
MD5 44d5e009f8c074e3f012eb692502cea9
BLAKE2b-256 aa712ff27c9413a7e71a17b7d002aafbf116e8c3bb8ed2c52a8231655a01c42a

See more details on using hashes here.

File details

Details for the file reverse_argparse-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for reverse_argparse-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b7ab85bae7948d2838e0e841245d865bca2f14101ad06783f988c74a78d1f891
MD5 9b8188ef9a9005368f51a21049807c5a
BLAKE2b-256 29a5bb02ac34f3ef6b53d916acc28c038a63983a7a3a58e1e2fb5de13e35c655

See more details on using hashes here.

Supported by

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