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()
def f1(x: int, y: int):
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.1.15.tar.gz
(5.7 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.1.15.tar.gz.
File metadata
- Download URL: rdee_easyarg-25.1.15.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a61e2085f8778d4bdbdf70fac4cebf9e3835e93bd03f03f554ba0a3d9e3a0e5
|
|
| MD5 |
94280f2adcd70de3869598b6803ef40e
|
|
| BLAKE2b-256 |
b4bdcce9f5c3c8eb48c8edd85f582f5ae813c318463273f3c594aa90ac95c2d0
|
File details
Details for the file rdee_easyarg-25.1.15-py2.py3-none-any.whl.
File metadata
- Download URL: rdee_easyarg-25.1.15-py2.py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d5e8e7d5d67166c53fb39f4810241a0548d2f68c549d1226c97a2e15b0443c3
|
|
| MD5 |
be0aaeaaa09ad188736b24db7f6ff24e
|
|
| BLAKE2b-256 |
bf02d1a4c45817ffd03d15ec05013e58c947eb53b9fab5714249db83016a2a6a
|