Skip to main content

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.

Usage

cli 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"):
    ...
python main.py train --help
>>> usage: main.py [-h] --model_name MODEL_NAME [--data_path DATA_PATH]

options:
  -h, --help               show this help message and exit
  --model_name MODEL_NAME  str
  --data_path DATA_PATH    str (default ./path/to/data)

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

upycli-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

upycli-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file upycli-0.1.0.tar.gz.

File metadata

  • Download URL: upycli-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for upycli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70f8fe7cdfc392e217904a270a11ef9a48f1e351aa698186dd6bdbe580e2a58f
MD5 e4bf2c037709f4424d39b45b32b030f4
BLAKE2b-256 7d976ea1415bbedc003950312f0c4d9610af6eeead3c2c1716f754429bfce9f2

See more details on using hashes here.

File details

Details for the file upycli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: upycli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for upycli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d8b131f417a0393e0fb655b2b2aa19709f88de09a0246e0afe4b70dc4156446
MD5 718b5282ee4c33a1fa7f4b64225313de
BLAKE2b-256 e06c18350137ba8261210af94daa61e143226d4b8f18163c4f6736327ba07ccf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page