From eb0ca027a94628f9964ff9078013721a89d2311f Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 2 Jan 2020 08:16:58 -0800 Subject: [PATCH] Fix having more than one add_argument decorator --- amanuensis/cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amanuensis/cli.py b/amanuensis/cli.py index 27f58fc..32e6cb2 100644 --- a/amanuensis/cli.py +++ b/amanuensis/cli.py @@ -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