Skip to content

Commit cf8a912

Browse files
committed
Autocomplete shorthand examples
Amazing. Still has some kinks to work out.
1 parent cf48b10 commit cf8a912

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

awsshell/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def get_completions(self, document, complete_event):
5959
else:
6060
display_text = completion
6161
display_meta = ''
62-
yield Completion(completion, -len(word_before_cursor),
62+
if text_before_cursor and text_before_cursor[-1] == ' ':
63+
location = 0
64+
else:
65+
location = -len(word_before_cursor)
66+
yield Completion(completion, location,
6367
display=display_text, display_meta=display_meta)
6468

6569

awsshell/autocomplete.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ def autocomplete(self, line):
8282
if next_command is not None:
8383
self._current = next_command
8484
self._current_name = last_word
85+
elif last_word in self.arg_metadata and \
86+
self.arg_metadata[last_word]['example']:
87+
# Then this is an arg with a shorthand example so we'll
88+
# suggest that example.
89+
return [self.arg_metadata[last_word]['example']]
8590
# Even if we don't change context, we still want to
8691
# autocomplete all the commands for the current context
8792
# in either of the above two cases.

0 commit comments

Comments
 (0)