Skip to main content

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/--help for 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 2 to execute the function "add"

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

rdee_easyarg-25.2.22.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdee_easyarg-25.2.22-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2Python 3

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

Hashes for rdee_easyarg-25.2.22.tar.gz
Algorithm Hash digest
SHA256 0d7426e60c172be8d8c5670f41bdd0010bba1347d7ca2beeb5283df924174134
MD5 4972cf6f1d8422500974846769a81f98
BLAKE2b-256 eaf4db28477377d2cd7641ef389af3c0a990648f6698605f56b208ff98162196

See more details on using hashes here.

File details

Details for the file rdee_easyarg-25.2.22-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rdee_easyarg-25.2.22-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7227e8c9b9d50520ad70ef5b8f68972217306ceba9cc69610df01ae40e8fb762
MD5 3c55925b88331be820937297565a956f
BLAKE2b-256 b33eeba70b7647560a418a925b82e8f015f89eb9694475e377542f54a8554b00

See more details on using hashes here.

Supported by

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