summaryrefslogtreecommitdiff
path: root/cmd2/argparse_completer.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-10 19:09:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-10 19:09:22 -0400
commitebd6668db1a4a1dfcf2937559f2fbe5a4f58dc48 (patch)
tree84ca344b8f0c1fb489d3ecea30a7e6392f0500d8 /cmd2/argparse_completer.py
parent9b43502ab70d1bd013a4cdede4805c2c0819c8c4 (diff)
downloadcmd2-git-ebd6668db1a4a1dfcf2937559f2fbe5a4f58dc48.tar.gz
Fixed issue where flag at beginning of REMAINDER section was tab completing
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r--cmd2/argparse_completer.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py
index d98ab8c5..77a62b9d 100644
--- a/cmd2/argparse_completer.py
+++ b/cmd2/argparse_completer.py
@@ -440,16 +440,6 @@ class AutoCompleter(object):
# Only start at the start token index
if idx >= self._token_start_index:
- # all args after -- are non-flags
- if remainder['arg'] is None and token == '--':
- flag_action = None
- flag_arg.reset()
- if is_last_token:
- break
- else:
- skip_remaining_flags = True
- continue
-
# If a remainder action is found, force all future tokens to go to that
if remainder['arg'] is not None:
if remainder['action'] == pos_action:
@@ -482,6 +472,14 @@ class AutoCompleter(object):
# 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]