Skip to main content

Lightweight native Python command-line interface argument builder

Project description

Aga is a lightweight native Python library for quickly creating documented command-line interfaces using argparse. It is designed to be as simple as possible to use.

Usage

Using Aga couldn't be easier. Assume the file below is named test.py:

from aga import *


@aga.add_arg
def add(first: int, second: int = 2) -> int:
    """ A simple function to add two numbers

    Args:
        first: One of the numbers to add
        second: The other number to add

    Returns:
        first added to second
    """

    return x + y


if __name__ == '__main__':
    aga.bake()
    print(aga.args.first, aga.args.second)

This simple file will result in the x and y arguments as shown below in the output of python test.py -h.

❯ python test.py -h
usage: test.py [-h] [-s] [-f]

options:
  -h, --help      show this help message and exit
  -s , --second   The other number to add
  -f , --first    One of the numbers to add

As you can see, one must simply add the decorator aga.add_arg to a function and Aga will parse the function definition and create a documented command-line interface.

Aga will search for PEP484 type annotations, default values and Google-style docstrings to add further information to the argument definition. None of these are necessary however, and if one (or all) are missing it will simply be ignored.

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

py_aga-0.1.4.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

py_aga-0.1.4-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file py_aga-0.1.4.tar.gz.

File metadata

  • Download URL: py_aga-0.1.4.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for py_aga-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3c085223ce653e106d879a6a4bd484ec29b3d5cbe858cb0d3ccb275f68c2ebb9
MD5 c3c54250587a5b304310383e263471eb
BLAKE2b-256 7b6bcf18e77d2afd73b7b85a3b2fca6ef946356237e48ebfc42f0637305e31b3

See more details on using hashes here.

File details

Details for the file py_aga-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: py_aga-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for py_aga-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c924caeecbd78e97d4becf11a49531399ec34ac2869296234421b3848401a62e
MD5 458aa54f6fdf6a19ba893b4f6705bf47
BLAKE2b-256 6f6361b467ff82e3f418fa40c20dabf3c05aff2f819d372ecccc3391c405bedf

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