summaryrefslogtreecommitdiff
path: root/cmd2/argparse_custom.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-30 11:13:47 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-30 11:13:47 -0400
commit179475c3fdb016aa33e69ba2888ff92e01c42869 (patch)
tree5ae857fef44694c8fcfb5b2fe7a9698dca9e0c6a /cmd2/argparse_custom.py
parent9d9e449bba87500b0b7bd83fa35417ef6d66ba08 (diff)
parenta5e52820df8da804347ef5a59519758f547bcb0f (diff)
downloadcmd2-git-179475c3fdb016aa33e69ba2888ff92e01c42869.tar.gz
Merge branch 'master' into make_history_directory
Diffstat (limited to 'cmd2/argparse_custom.py')
-rw-r--r--cmd2/argparse_custom.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py
index da5410d0..5432314b 100644
--- a/cmd2/argparse_custom.py
+++ b/cmd2/argparse_custom.py
@@ -346,13 +346,17 @@ def _add_argument_wrapper(self, *args,
new_arg = orig_actions_container_add_argument(self, *args, **kwargs)
# Verify consistent use of arguments
- choice_params = [new_arg.choices, choices_function, choices_method, completer_function, completer_method]
- num_set = len(choice_params) - choice_params.count(None)
+ choices_params = [new_arg.choices, choices_function, choices_method, completer_function, completer_method]
+ num_params_set = len(choices_params) - choices_params.count(None)
- if num_set > 1:
- err_msg = ("Only one of the following may be used in an argparser argument at a time:\n"
+ if num_params_set > 1:
+ err_msg = ("Only one of the following parameters may be used at a time:\n"
"choices, choices_function, choices_method, completer_function, completer_method")
raise (ValueError(err_msg))
+ elif num_params_set > 0 and new_arg.nargs == 0:
+ err_msg = ("None of the following parameters can be used for this type of action:\n"
+ "choices, choices_function, choices_method, completer_function, completer_method")
+ raise (TypeError(err_msg))
# Set the custom attributes
setattr(new_arg, ATTR_NARGS_RANGE, nargs_range)