diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-27 17:34:06 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-27 17:34:06 -0400 |
commit | ef999cf0b5b058b8617e2bdf6e9a13e7da3d2198 (patch) | |
tree | 6b73536e310117525c29e1cc122725b320bc8c7a /cmd2/argparse_completer.py | |
parent | 372c37936b5bfa8dc1911cdf6ca7a24c4f697c4f (diff) | |
download | cmd2-git-ef999cf0b5b058b8617e2bdf6e9a13e7da3d2198.tar.gz |
Allowing flag in mutex group to appear more than once
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r-- | cmd2/argparse_completer.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index f3adf105..c1200ae5 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -185,9 +185,16 @@ class AutoCompleter(object): # Check if the group this action belongs to has already been completed if group in completed_mutex_groups: + + # If this is the action that completed the group, then there is no error + # since it's allowed to appear on the command line more than once. + completer_action = completed_mutex_groups[group] + if arg_action == completer_action: + return True + error = style_error("\nError: argument {}: not allowed with argument {}\n". format(argparse._get_action_name(arg_action), - argparse._get_action_name(completed_mutex_groups[group]))) + argparse._get_action_name(completer_action))) self._print_message(error) return False |