def argument(*args, **kwargs):
"""Decorator to define an argparse option or argument.
The arguments to this decorator are the same as the
`ArgumentParser.add_argument <https://docs.python.org/3/library/\
argparse.html#the-add-argument-method>`_
method.
"""
def decorator(f):
if not hasattr(f, '_arguments'):
f._arguments = []
if not hasattr(f, '_argnames'):
f._argnames = []
f._arguments.append((args, kwargs))
f._argnames.append(_get_dest(*args, **kwargs))
return f
return decorator
评论列表
文章目录