Generate the effective command line invocation for a script.
Project description
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
Built Distribution
File details
Details for the file reverse_argparse-1.0.8.tar.gz
.
File metadata
- Download URL: reverse_argparse-1.0.8.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b38cca398edfa464ffdc2c19ea8548d5a7348e5d865a2b84914f9ad5835839c6 |
|
MD5 | 940f0c88ea33435d79b66f5937133d3e |
|
BLAKE2b-256 | 43fec7b812ca38d2e45ac33e169eed28ff2ac46af3bd6f442a098d05375a2089 |
File details
Details for the file reverse_argparse-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: reverse_argparse-1.0.8-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 003d4055534c5f459426a4302b203aa73d53a1e78ab6877a252cba0d09a6e843 |
|
MD5 | c36e6e2c53ebb382765d52abee0ab6c5 |
|
BLAKE2b-256 | cde775b331ef8f35cf06e2d0e1500e1d6162c2bbe79cf6b356fec9c8c3209c00 |