30
30
31
31
32
32
LOG = logging .getLogger (__name__ )
33
+ EXIT_REQUESTED = object ()
33
34
34
35
35
36
def create_aws_shell (completer , model_completer , docs ):
@@ -82,9 +83,16 @@ def run(self, command, application):
82
83
p .communicate ()
83
84
84
85
86
+ class ExitHandler (object ):
87
+ def run (self , command , application ):
88
+ return EXIT_REQUESTED
89
+
90
+
85
91
class DotCommandHandler (object ):
86
92
HANDLER_CLASSES = {
87
93
'edit' : EditHandler ,
94
+ 'exit' : ExitHandler ,
95
+ 'quit' : ExitHandler ,
88
96
}
89
97
90
98
def __init__ (self , output = sys .stdout , err = sys .stderr ):
@@ -109,7 +117,7 @@ def handle_cmd(self, command, application):
109
117
else :
110
118
# Note we expect the class to support no-arg
111
119
# instantiation.
112
- self .HANDLER_CLASSES [cmd_name ]().run (parts , application )
120
+ return self .HANDLER_CLASSES [cmd_name ]().run (parts , application )
113
121
114
122
def _unknown_cmd (self , cmd_parts , application ):
115
123
self ._err .write ("Unknown dot command: %s\n " % cmd_parts [0 ])
@@ -204,12 +212,12 @@ def run(self):
204
212
self .save_config ()
205
213
break
206
214
else :
207
- if text .strip () in ['quit' , 'exit' ]:
208
- break
209
215
if text .startswith ('.' ):
210
216
# These are special commands. The only one supported for
211
217
# now is .edit.
212
- self ._dot_cmd .handle_cmd (text , application = self )
218
+ result = self ._dot_cmd .handle_cmd (text , application = self )
219
+ if result is EXIT_REQUESTED :
220
+ break
213
221
else :
214
222
if text .startswith ('!' ):
215
223
# Then run the rest as a normally shell command.
0 commit comments