Argmagic
Based on a idea by @lbb.
Automatically generate argparse based env-var/CLI-interface from a given function.
Example:
Given a function with a docstring and type hints.
def hello(name: str):
'''
Say hello to name.
Args:
name: Your name.
Raises:
Nothing.
Returns:
Nothing.
'''
print('Hello', name)
Create a CLI interface:
argmagic(hello)
Argmagic will call the function with all parameters filled from CLI arguments.
$ ./hello.py -h
usage: hello [-h] [--name NAME]
Say hello to name.
optional arguments:
-h, --help show this help message and exit
--name NAME Your name.
Additionally all specified parameters can also be defined via environment variables.
$ NAME=test hello.py
Hello test
These can then again be overriden by CLI arguments.
$ NAME=test hello.py --name something
Hello something
Support of composite types
Current parsing of lists, tuples and unions are supported.
For example a typehint containing List[str], will parse input [a, b, c] to
a python list containing ["a", "b", "c"].
Also these types can be arbitrarily nested, such as Dict[str, List[int]] will
correctly parse strings of structure {a: [1, 2, 3], b: [5, 3]}.
Syntax overview:
Tuple syntax:
(a, b, c)
List syntax:
[a, b, c]
Dict syntax:
{a: i, b: j, k: l}
Alternatives
click uses decorators
Metadata
Release files for argmagic 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argmagic-1.0.1.tar.gz | 5.4 kB | Without provenance | Details for argmagic-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| argmagic-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for argmagic-1.0.1-py3-none-any.whl |
Total release size: 11.8 kB
Release files / argmagic-1.0.1.tar.gz
| Download URL | argmagic-1.0.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdebda19fd8cb8f44d4d4a4d65a20bf02105da638c2d8cf1cfce6a658147bdfc
|
|
BLAKE2b-256 checksum How to use checksums |
18d242aa2c03d99000786488338935bf4e4b0f84479fe473bd85788d5a1c955a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8
|
Release files / argmagic-1.0.1-py3-none-any.whl
| Download URL | argmagic-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5069fad4940a699e51f5750f47c27f2b5668de979c767eca2b13b9cc9ced2ba
|
|
BLAKE2b-256 checksum How to use checksums |
c88afcbfda45ab674a2c76af2d9e9192841de2f7e01272af412e90320513d1ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8
|
Security for argmagic 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.