Skip to content

Commit c3e466f

Browse files
committed
Merge branch 'global-arg-metadata'
* global-arg-metadata: Merge in global arg metadata with arg_metadata
2 parents 8adf480 + afe93d7 commit c3e466f

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
@@ -78,6 +78,7 @@ def _convert_to_prompt_completions(self, low_level_completions,
7878
# prompt_toolkit. We also try to enhance the metadata of the
7979
# completion by including docs and marking required fields.
8080
arg_meta = self._completer.arg_metadata
81+
arg_meta.update(self._completer.global_arg_metadata)
8182
word_before_cursor = ''
8283
if text_before_cursor.strip():
8384
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)