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()
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/--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.1.16.tar.gz (5.7 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.1.16-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rdee_easyarg-25.1.16.tar.gz.

File metadata

  • Download URL: rdee_easyarg-25.1.16.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for rdee_easyarg-25.1.16.tar.gz
Algorithm Hash digest
SHA256 00919ffc5537583d28db01ac3e02899fd1064abf959ecb4a0c6e104c1dfe0ae0
MD5 a2dc219fcbd5ac5985a26bf048ad55e5
BLAKE2b-256 d3227fd1b0ec80515fc1dc662b3eddb1f481ee60c584d20846b00a0b1f169cc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rdee_easyarg-25.1.16-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7233ab16356a8135f150af02a25c07be7ef46662c879eddeaa6a6259ef28d409
MD5 d84a24e5a2478d3c7e38285dda038345
BLAKE2b-256 c8fc8825fce7cb2cb54d0d167488cbeb5d33bf3a17ba0edcd78aa7bdbaf3c115

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