Skip to content

Commit

Permalink
Completions ignore unrecognized command args (#5993)
Browse files Browse the repository at this point in the history
* small bug with completer

* added test
  • Loading branch information
williexu authored Apr 3, 2018
1 parent 403bcad commit a7cd9bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-interactive/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.3.19
++++++
* Stops completions upon unrecognized commands.

0.3.18
++++++
* Completions kick in as soon as command table loading is done.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def gen_cmd_and_param_completions(self):
for param in self.command_param_info.get(self.current_command, []):
if self.validate_param_completion(param, self.leftover_args):
yield self.yield_param_completion(param, self.unfinished_word)
else:
elif not self.leftover_args:
for child_command in self.subtree.children:
if self.validate_completion(child_command):
yield Completion(child_command, -len(self.unfinished_word))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ def verify_completions(self, generated_completions, expected_completions, start_
def init_completer(self):
with mock.patch.object(Configuration, 'get_help_files', lambda _: 'help_dump_test.json'):
with mock.patch.object(Configuration, 'get_config_dir', lambda _: TEST_DIR):
print(TEST_DIR)
shell_ctx = AzInteractiveShell(TestCli(), None)
self.completer = shell_ctx.completer
print(self.completer.command_tree.children)

def test_command_completion(self):
# tests some azure commands
Expand Down Expand Up @@ -75,6 +73,12 @@ def test_command_completion(self):
completions = set(['vm', 'vmss'])
self.verify_completions(gen, completions, -2)

# test unrecognized command does not complete
doc = Document(u'vm group ')
gen = self.completer.get_completions(doc, None)
completions = set()
self.verify_completions(gen, completions, 0)

def test_param_completion(self):
# tests some azure params
self.init_completer()
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-interactive/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
cmdclass = {}

# Version is also defined in azclishell.__init__.py.
VERSION = "0.3.18"
VERSION = "0.3.19"
# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
Expand Down

0 comments on commit a7cd9bf

Please sign in to comment.