3
3
Main entry point to the AWS Shell.
4
4
5
5
"""
6
+ import tempfile
7
+ import subprocess
8
+
6
9
from prompt_toolkit .document import Document
7
10
from prompt_toolkit .shortcuts import create_eventloop
8
11
from prompt_toolkit .buffer import Buffer
9
- from prompt_toolkit .enums import DEFAULT_BUFFER , SEARCH_BUFFER
10
- from prompt_toolkit .filters import IsDone , HasFocus , Always , RendererHeightIsKnown , to_cli_filter
11
- from prompt_toolkit .interface import CommandLineInterface , Application , AbortAction , AcceptAction
12
+ from prompt_toolkit .filters import Always
13
+ from prompt_toolkit .interface import CommandLineInterface , Application
14
+ from prompt_toolkit .interface import AbortAction , AcceptAction
12
15
from prompt_toolkit .key_binding .manager import KeyBindingManager
13
- from prompt_toolkit .layout import Window , HSplit , VSplit , FloatContainer , Float
14
- from prompt_toolkit .layout .containers import ConditionalContainer
15
- from prompt_toolkit .layout .controls import BufferControl , TokenListControl , FillControl
16
- from prompt_toolkit .layout .dimension import LayoutDimension
17
- from prompt_toolkit .layout .menus import CompletionsMenu , MultiColumnCompletionsMenu
18
- from prompt_toolkit .layout .processors import PasswordProcessor , HighlightSearchProcessor , \
19
- HighlightSelectionProcessor , ConditionalProcessor
20
- from prompt_toolkit .layout .prompt import DefaultPrompt
21
- from prompt_toolkit .layout .screen import Char
22
- from prompt_toolkit .layout .toolbars import ValidationToolbar , SystemToolbar , ArgToolbar , SearchToolbar
23
- from prompt_toolkit .layout .utils import explode_tokens
24
16
from prompt_toolkit .utils import Callback
25
- from pygments .token import Token
26
17
27
- from awsshell .compat import text_type
28
18
from awsshell .ui import create_default_layout
29
19
30
20
@@ -55,13 +45,13 @@ def run(self):
55
45
if text .strip () in ['quit' , 'exit' ]:
56
46
break
57
47
if text .startswith ('.' ):
58
- # These are special commands. The only one supported for now
59
- # is .edit.
48
+ # These are special commands. The only one supported for
49
+ # now is .edit.
60
50
if text .startswith ('.edit' ):
61
- # Hardcoded VIM editor for now. It's for demo purposes!
51
+ # TODO: Use EDITOR env var.
62
52
all_commands = '\n ' .join (
63
53
['aws ' + h for h in list (self .history )
64
- if not h .startswith (('.' , '!' ))])
54
+ if not h .startswith (('.' , '!' ))])
65
55
with tempfile .NamedTemporaryFile ('w' ) as f :
66
56
f .write (all_commands )
67
57
f .flush ()
@@ -81,15 +71,13 @@ def create_layout(self):
81
71
u'aws> ' , reserve_space_for_menu = True ,
82
72
display_completions_in_columns = True )
83
73
84
-
85
74
def create_buffer (self , completer , history ):
86
75
return Buffer (
87
76
history = history ,
88
77
completer = completer ,
89
78
complete_while_typing = Always (),
90
79
accept_action = AcceptAction .RETURN_DOCUMENT )
91
80
92
-
93
81
def create_application (self , completer , history ):
94
82
key_bindings_registry = KeyBindingManager (
95
83
enable_vi_mode = True ,
@@ -109,13 +97,12 @@ def create_application(self, completer, history):
109
97
key_bindings_registry = key_bindings_registry ,
110
98
)
111
99
112
-
113
100
def on_input_timeout (self , cli ):
114
101
buffer = cli .current_buffer
115
102
document = buffer .document
116
103
text = document .text
117
- cli .buffers ['clidocs' ].reset (initial_document = Document ( text , cursor_position = 0 ))
118
-
104
+ cli .buffers ['clidocs' ].reset (
105
+ initial_document = Document ( text , cursor_position = 0 ))
119
106
120
107
def create_cli_interface (self ):
121
108
# A CommandLineInterface from prompt_toolkit
0 commit comments