summaryrefslogtreecommitdiff
path: root/cmd2/argparse_completer.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-12 17:47:30 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-12 17:47:30 -0400
commit0b9794ab065c7f981fe8841e53c8cb7805026dcc (patch)
tree2694269caede9e21e2528a858a0ef9dbdbc9e5a9 /cmd2/argparse_completer.py
parent5d1fcdba6f1674b46629e92bb3075c12d706af5f (diff)
downloadcmd2-git-0b9794ab065c7f981fe8841e53c8cb7805026dcc.tar.gz
Added more hint unit tests
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r--cmd2/argparse_completer.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py
index 3a5cb64c..ae82a4a7 100644
--- a/cmd2/argparse_completer.py
+++ b/cmd2/argparse_completer.py
@@ -187,7 +187,9 @@ class AutoCompleter(object):
consumed_arg_values.setdefault(arg_state.action.dest, [])
consumed_arg_values[arg_state.action.dest].append(token)
- # Enumerate over the sliced list up to the token being completed
+ #############################################################################################
+ # Parse all but the last token
+ #############################################################################################
for loop_index, token in enumerate(tokens[self._token_start_index:-1]):
# If we're in a positional REMAINDER arg, force all future tokens to go to that
@@ -304,7 +306,10 @@ class AutoCompleter(object):
self._positional_actions[next_pos_arg_index].nargs == argparse.REMAINDER:
skip_remaining_flags = True
- # We have now parsed all tokens up to the one being completed and have enough information to do so.
+ #############################################################################################
+ # We have parsed all but the last token and have enough information to complete it
+ #############################################################################################
+
# Check if we are completing a flag name. This check ignores strings with a length of one, like '-'.
# This is because that could be the start of a negative number which may be a valid completion for
# the current argument. We will handle the completion of flags that start with only one prefix