rdee-series toolkits: python-easyarg
Project description
rdee-python-easyarg
- Used to run any function with generic arguments from CLI
- Support two modes: CLI app or CLI executor
Install
pip install rdee-easyarg
Examples
CLI-app mode
- In this mode, we use a decorator to generate CLI interface automatically, mimicing typer in general
import easyarg
ea = easyarg.EasyArg()
@ea.command(name="func1", alias="f")
def f1(x: int, y: int, flag1: bool, flag2: bool = False):
"""
:param x: this info will be read as argument description in -h, --help
"""
print(x+y)
if __name__ == "__main__":
ea.parse()
- You can run the script directly, such as
./a.py f1 --x 1 --y 2, and get 3 -h/--helpfor app level and function level are both supported
CLI-executor mode
- In this mode, we can run a function without modifying any of its code
- For instance, given the
funcs.py
def add(x: int, y: int = 0) -> int:
print(x + y)
def mul(a: float, B: float, c: float = 1.0) -> float:
print(a * B * c)
- just run
python -m easyarg funcs.py add --x 1 --y 2to execute the function "add"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rdee_easyarg-25.2.22.tar.gz
(8.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rdee_easyarg-25.2.22.tar.gz.
File metadata
- Download URL: rdee_easyarg-25.2.22.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d7426e60c172be8d8c5670f41bdd0010bba1347d7ca2beeb5283df924174134
|
|
| MD5 |
4972cf6f1d8422500974846769a81f98
|
|
| BLAKE2b-256 |
eaf4db28477377d2cd7641ef389af3c0a990648f6698605f56b208ff98162196
|
File details
Details for the file rdee_easyarg-25.2.22-py2.py3-none-any.whl.
File metadata
- Download URL: rdee_easyarg-25.2.22-py2.py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7227e8c9b9d50520ad70ef5b8f68972217306ceba9cc69610df01ae40e8fb762
|
|
| MD5 |
3c55925b88331be820937297565a956f
|
|
| BLAKE2b-256 |
b33eeba70b7647560a418a925b82e8f015f89eb9694475e377542f54a8554b00
|