A microscopic library to turn any function into a CLI.
Project description
uPyCLI
A microscopic library to turn any function into a CLI.
Takes some inspiration from pycli although I didn't know
this existed before starting. This lib is even smaller than pycli and does not require any setup
and has no dependencies.
The good thing about this is, you don't need to write or maintain any code for the CLI, all your types, variables, descriptions are introspected from the code itself, so all you do is throw on a decorator.
Usage
ucli path.to.your.function --help
For this to work, all you need to do is have a function in the module with the right type-annotations and all optional values should have a default value.
# Here model_name is required and data_path is optional
def train(
model_name: str,
data_path: str = "./path/to/data"):
...
Alternatively, the command decorator can be used to directly turn the function into a CLI command
# main.py
from upycli.decorator import command
@command
def train(model_name: str, data_path: str = "./path/to/data"):
"""
A function to train a model
"""
...
python main.py train --help
>>> usage: main.py [-h] --model_name MODEL_NAME [--data_path DATA_PATH]
A function to train a model
options:
-h, --help show this help message and exit
--model_name MODEL_NAME str
--data_path DATA_PATH str (default ./path/to/data)
Your variables, types, required values and description are introspected from the code itself, so all you do is throw on the decorator.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 upycli-0.2.11.tar.gz.
File metadata
- Download URL: upycli-0.2.11.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
190852a1d590addebd1f8cf9f8dc9bc25508533e2248f9ba7d326d3855c2b8c1
|
|
| MD5 |
073e49eda92206d7a884543ddf53347e
|
|
| BLAKE2b-256 |
47fb50637d29a27ef7527dd0aaffb6b11fd9575a0df22117aedbc8c7eb60fd83
|
Provenance
The following attestation bundles were made for upycli-0.2.11.tar.gz:
Publisher:
python-publish.yml on zrthxn/uPyCLI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
upycli-0.2.11.tar.gz -
Subject digest:
190852a1d590addebd1f8cf9f8dc9bc25508533e2248f9ba7d326d3855c2b8c1 - Sigstore transparency entry: 149300880
- Sigstore integration time:
-
Permalink:
zrthxn/uPyCLI@08534cc5a9d41c02f778250c8e4dc0b2792aa40b -
Branch / Tag:
refs/tags/v0.2.11 - Owner: https://github.com/zrthxn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08534cc5a9d41c02f778250c8e4dc0b2792aa40b -
Trigger Event:
release
-
Statement type:
File details
Details for the file upycli-0.2.11-py3-none-any.whl.
File metadata
- Download URL: upycli-0.2.11-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0297e848c2ee6ac1225f5083bab652956268f960fa52d1db09c0e6b9ebbaef61
|
|
| MD5 |
6bd1e3164da6d0d2e03d3f8654bd6d50
|
|
| BLAKE2b-256 |
0f79e50afe643f17c95bf06bd6c857f4e9b032e55107737e6fb4d9de56756605
|
Provenance
The following attestation bundles were made for upycli-0.2.11-py3-none-any.whl:
Publisher:
python-publish.yml on zrthxn/uPyCLI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
upycli-0.2.11-py3-none-any.whl -
Subject digest:
0297e848c2ee6ac1225f5083bab652956268f960fa52d1db09c0e6b9ebbaef61 - Sigstore transparency entry: 149300882
- Sigstore integration time:
-
Permalink:
zrthxn/uPyCLI@08534cc5a9d41c02f778250c8e4dc0b2792aa40b -
Branch / Tag:
refs/tags/v0.2.11 - Owner: https://github.com/zrthxn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08534cc5a9d41c02f778250c8e4dc0b2792aa40b -
Trigger Event:
release
-
Statement type: