Skip to main content

Decorators and wrapper makes argparse and CLI more easy

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

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

ArgParseInator-1.0.18.tar.gz (15.0 kB view hashes)

Uploaded Source

Built Distribution

ArgParseInator-1.0.18-py2.py3-none-any.whl (22.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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