https://github.com/mbdevpl/argunparse
Reversed argparse: generate string of command-line args from Python objects.
https://github.com/mbdevpl/argunparse
argparse commandline-arguments jenkins-enabled pretty-printing unparsing
Last synced: about 2 months ago
JSON representation
Reversed argparse: generate string of command-line args from Python objects.
- Host: GitHub
- URL: https://github.com/mbdevpl/argunparse
- Owner: mbdevpl
- License: apache-2.0
- Created: 2016-09-07T11:17:18.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2023-09-23T09:06:46.000Z (about 2 years ago)
- Last Synced: 2024-12-15T23:31:34.412Z (10 months ago)
- Topics: argparse, commandline-arguments, jenkins-enabled, pretty-printing, unparsing
- Language: Python
- Homepage:
- Size: 88.9 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. role:: bash(code)
:language: bash.. role:: python(code)
:language: python==========
argunparse
==========Reversed argparse: generate string of command-line args from Python objects.
.. image:: https://img.shields.io/pypi/v/argunparse.svg
:target: https://pypi.org/project/argunparse
:alt: package version from PyPI.. image:: https://github.com/mbdevpl/argunparse/actions/workflows/python.yml/badge.svg?branch=main
:target: https://github.com/mbdevpl/argunparse/actions
:alt: build status from GitHub.. image:: https://codecov.io/gh/mbdevpl/argunparse/branch/main/graph/badge.svg
:target: https://codecov.io/gh/mbdevpl/argunparse
:alt: test coverage from Codecov.. image:: https://api.codacy.com/project/badge/Grade/fd6a7e9ac9324d9f9b5d1e77d10000e4
:target: https://app.codacy.com/gh/mbdevpl/argunparse
:alt: grade from Codacy.. image:: https://img.shields.io/github/license/mbdevpl/argunparse.svg
:target: NOTICE
:alt: licenseThe *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::
:backlinks: noneHow to use
==========Simple example of how *argunparse* works:
.. code:: python
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.txtprint(unparser.unparse_to_list(*args, **options))
# ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']Special option values are:
* :python:`True` -- option will be treated as a flag;
* :python:`False` and :python:`None` -- option will be ignored.All other values will be converted to strings using :python:`str()`.
For more examples see ``_ notebook.
Requirements
============Python version 3.11 or later.
Python libraries as specified in ``_.
Building and running tests additionally requires packages listed in ``_.
Tested on Linux, macOS and Windows.
Installation
============For simplest installation use :bash:`pip`:
.. code:: bash
pip3 install argunparse
Links
=====- *argparse*:
https://docs.python.org/3/library/argparse.html