a library that wraps argparse, mapping arguments to decorated functions
functions are only called if the associated command line argument is present/non-empty
$ pip install argrun
from functools import reduce
import argrun
runner = argrun.ArgumentRunner()
@runner.parse('-m', '--multiply', help='multiplies numbers', nargs='*')
def multiply(args):
print(reduce(lambda x,y: x * y, map(int, args)))
if __name__ == '__main__':
runner.run()
See also argparse
ArgumentRunner(self)
ArgumentRunner offers a decorator, parses arguments, and allows decorated functions to be ran
ArgumentRunner.parse_args(*args, **kwargs)
Parses arguments and returns the result as a dictionary
ArgumentRunner.parse(*args, **kwargs)
a decorator that defines the arguments to be parsed and associates it with the decorated method
ArgumentRunner.run(*args, **kwargs)
Runs all decorated functions
ArgumentRunner.add_argument(*args, **kwargs)
adds an argument to be parsed without being run