Cli arguments

A set of decorators that are related to command line interface (CLI) arguments.

@cli_yaml

The @cli_yaml (and @cli_json alike) provides a convenient way to read the contents of a YAML file and pass them as arguments to a function directly.

usage

demo.yaml

name: "adrian"
age: 28

demo.py

from pyDeco.cli import cli_yaml

@cli_yaml
def func(name: str, age: int):
    print(f"{name} is {age} years old.")

func()

run command

$ python demo.py --yaml ./demo.yaml

output

adrian is 28 years old.

@cli_json

Same as above