| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Reversed argparse: generate string of command-line args from Python objects.
The argunparse is intended to perform an approximate reverse of what argparse does. In short: generating string (or a list of strings) of command-line arguments from a dict and/or a list.
Contents
Simple example of how argunparse works:
import argunparse
options = {
'v': True,
'long-flag': True,
'ignored': False,
'also-ignored': None,
'o': 'out_file.txt',
'log': 'log_file.txt'
}
args = {
'in_file.txt'
}
unparser = argunparse.ArgumentUnparser()
print(unparser.unparse(*args, **options))
# -v --long-flag -o=out_file.txt --log=log_file.txt in_file.txt
print(unparser.unparse_to_list(*args, **options))
# ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']Special option values are:
All other values will be converted to strings using str().
For more examples see examples.ipynb notebook.
Python version 3.11 or later.
Python libraries as specified in requirements.txt.
Building and running tests additionally requires packages listed in requirements_test.txt.
Tested on Linux, macOS and Windows.
For simplest installation use pip:
pip3 install argunparse| Back | FazBrowse Home | New Git URL |