Skip to main content

Decorators and wrapper for easily define script's arguments within functions and classes. just defining function's args.

Project description

ArgParseInator

Argparseinator is a silly, but useful, thing that permit you to easily add argparse’s arguments and options to your script directly within functions and classes with the use of some decorators.

Install

pip install argparseinator

Quick example (sayciao.py module)

"""
Say ciao script.
"""

__version__ = "1.2.3"


from argparseinator import ArgParseInator, arg


@arg()
def sayciao(name):
    """
    I will say ciao.
    """
    print "Ciao", name

if __name__ == '__main__':
    ArgParseInator().check_command()

call:

$ python sayciao.py --help

will output:

usage: sayciao.py [-h] [-v] name

Say ciao script.

    I will say ciao.


positional arguments:
  name

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit

call:

$ python sayciao.py --version

will output:

sayciao.py 1.2.3

call:

$ python sayciao.py luca

will output:

Ciao luca

Docs

See readthedocs

Supported by

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