summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-08 13:23:01 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-08 13:23:01 -0400
commitbdcc179661a16f9bf648f230e5713a81e391f083 (patch)
tree7594ec39b9db3137408498fcb650868c4d47dcb7 /cmd2
parent4a5b23284be04258735ba421f62825520651e14e (diff)
downloadcmd2-git-bdcc179661a16f9bf648f230e5713a81e391f083.tar.gz
Fixed issue where -- was not handled properly in AutoCompleter when the parser's prefix characters did not include -
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/argparse_completer.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py
index 1a156f8f..4a33fba3 100644
--- a/cmd2/argparse_completer.py
+++ b/cmd2/argparse_completer.py
@@ -321,21 +321,21 @@ class AutoCompleter(object):
self._positional_actions[next_pos_arg_index].nargs == argparse.REMAINDER:
skip_remaining_flags = True
+ # Handle '--' which tells argparse all remaining arguments are non-flags
+ if token == '--' and not skip_remaining_flags:
+ if is_last_token:
+ # Exit loop and see if -- can be completed into a flag
+ break
+ else:
+ skip_remaining_flags = True
+
# At this point we're no longer consuming flag arguments. Is the current argument a potential flag?
- if is_potential_flag(token, self._parser) and not skip_remaining_flags:
+ elif is_potential_flag(token, self._parser) and not skip_remaining_flags:
# reset some tracking values
flag_arg.reset()
# don't reset positional tracking because flags can be interspersed anywhere between positionals
flag_action = None
- if token == '--':
- if is_last_token:
- # Exit loop and see if -- can be completed into a flag
- break
- else:
- # In argparse, all args after -- are non-flags
- skip_remaining_flags = True
-
# does the token fully match a known flag?
if token in self._flag_to_action:
flag_action = self._flag_to_action[token]