Fix having more than one add_argument decorator

This commit is contained in:
Tim Van Baak 2020-01-02 08:16:58 -08:00
parent 6e22a92b78
commit eb0ca027a9
1 changed files with 3 additions and 1 deletions

View File

@ -21,12 +21,14 @@ from functools import wraps
def add_argument(*args, **kwargs):
"""Passes the given args and kwargs to subparser.add_argument"""
def argument_adder(command):
second_layer = command.__dict__.get('wrapper', False)
@wraps(command)
def augmented_command(cmd_args):
if type(cmd_args) is AP:
cmd_args.add_argument(*args, **kwargs)
else:
if type(cmd_args) is not AP or second_layer:
command(cmd_args)
augmented_command.__dict__['wrapper'] = True
return augmented_command
return argument_adder