Skip to content

Commit

Permalink
Merge in global arg metadata with arg_metadata
Browse files Browse the repository at this point in the history
Fixes #51.
  • Loading branch information
jamesls committed Dec 30, 2015
1 parent 9149483 commit afe93d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions awsshell/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def __init__(self, index_data, match_fuzzy=True):
self.cmd_path = [self._current_name]
self.match_fuzzy = match_fuzzy

@property
def global_arg_metadata(self):
return self._index[self._root_name]['argument_metadata']

@property
def arg_metadata(self):
# Returns the required arguments for the current level.
Expand Down
1 change: 1 addition & 0 deletions awsshell/shellcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _convert_to_prompt_completions(self, low_level_completions,
# prompt_toolkit. We also try to enhance the metadata of the
# completion by including docs and marking required fields.
arg_meta = self._completer.arg_metadata
arg_meta.update(self._completer.global_arg_metadata)
word_before_cursor = ''
if text_before_cursor.strip():
word_before_cursor = text_before_cursor.strip().split()[-1]
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
def index_data():
return {
'aws': {
'argument_metadata': {},
'arguments': [],
'commands': [],
'children': {},
Expand Down Expand Up @@ -370,3 +371,12 @@ def test_can_handle_autocomplete_empty_string_twice(index_data):
completer = AWSCLIModelCompleter(index_data)
assert completer.autocomplete('') == []
assert completer.autocomplete('') == []


def test_global_arg_metadata_property(index_data):
index_data['aws']['argument_metadata'] = {
'--global1': {},
'--global2': {},
}
completer = AWSCLIModelCompleter(index_data)
assert '--global1' in completer.global_arg_metadata

0 comments on commit afe93d7

Please sign in to comment.