Skip to content

Commit afe93d7

Browse files
committed
Merge in global arg metadata with arg_metadata
Fixes awslabs#51.
1 parent 9149483 commit afe93d7

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

awsshell/autocomplete.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def __init__(self, index_data, match_fuzzy=True):
2525
self.cmd_path = [self._current_name]
2626
self.match_fuzzy = match_fuzzy
2727

28+
@property
29+
def global_arg_metadata(self):
30+
return self._index[self._root_name]['argument_metadata']
31+
2832
@property
2933
def arg_metadata(self):
3034
# Returns the required arguments for the current level.

awsshell/shellcomplete.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _convert_to_prompt_completions(self, low_level_completions,
6262
# prompt_toolkit. We also try to enhance the metadata of the
6363
# completion by including docs and marking required fields.
6464
arg_meta = self._completer.arg_metadata
65+
arg_meta.update(self._completer.global_arg_metadata)
6566
word_before_cursor = ''
6667
if text_before_cursor.strip():
6768
word_before_cursor = text_before_cursor.strip().split()[-1]

tests/unit/test_autocomplete.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
def index_data():
66
return {
77
'aws': {
8+
'argument_metadata': {},
89
'arguments': [],
910
'commands': [],
1011
'children': {},
@@ -370,3 +371,12 @@ def test_can_handle_autocomplete_empty_string_twice(index_data):
370371
completer = AWSCLIModelCompleter(index_data)
371372
assert completer.autocomplete('') == []
372373
assert completer.autocomplete('') == []
374+
375+
376+
def test_global_arg_metadata_property(index_data):
377+
index_data['aws']['argument_metadata'] = {
378+
'--global1': {},
379+
'--global2': {},
380+
}
381+
completer = AWSCLIModelCompleter(index_data)
382+
assert '--global1' in completer.global_arg_metadata

0 commit comments

Comments
 (0)