Skip to content

Commit ef999cf

Browse files
committed
Allowing flag in mutex group to appear more than once
1 parent 372c379 commit ef999cf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd2/argparse_completer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,16 @@ def update_mutex_groups(arg_action: argparse.Action) -> bool:
185185

186186
# Check if the group this action belongs to has already been completed
187187
if group in completed_mutex_groups:
188+
189+
# If this is the action that completed the group, then there is no error
190+
# since it's allowed to appear on the command line more than once.
191+
completer_action = completed_mutex_groups[group]
192+
if arg_action == completer_action:
193+
return True
194+
188195
error = style_error("\nError: argument {}: not allowed with argument {}\n".
189196
format(argparse._get_action_name(arg_action),
190-
argparse._get_action_name(completed_mutex_groups[group])))
197+
argparse._get_action_name(completer_action)))
191198
self._print_message(error)
192199
return False
193200

0 commit comments

Comments
 (0)