Expose your Python functions to the command line with one easy step!
OTHER License
An unobtrusive, elegant mechanism to provide seamless command line interfaces through argparse for Python functions.
All you have to do is decorate your function of choice with @argexec
and away you go!
bool
, int
, float
, str
, bytes
)dynamic_dispatch
You may install this via the argexec
package on PyPi:
pip3 install argexec
The decorator may be applied to any Python function that meets the following requirements:
*args
or **kwargs
Example (foo.py
):
#!/usr/bin/python3
from typing import Tuple
from argexec import argexec
from argexec.types import LogLevel
@argexec
def _(w: int, x: Tuple[str, ...], y: LogLevel, z: bool = True):
"""
Hello, world!
:param w: foo.
:param x: bar.
:param y: baz.
:param z: qux.
"""
pass
$ ./foo.py --help
usage: foo.py [-h] [-y] [--no-z] w [x [x ...]]
Hello, world!
positional arguments:
w [int] foo
x [Tuple[str, ...]] bar
optional arguments:
-h, --help show this help message and exit
-y, --y [LogLevel=CRITICAL] baz (more flags for lower level)
--no-z [bool=True] qux
When developing, it is recommended to use Pipenv. To create your development environment:
pipenv install --dev
TODO