3030
3131
3232LOG = logging .getLogger (__name__ )
33+ EXIT_REQUESTED = object ()
3334
3435
3536def create_aws_shell (completer , model_completer , docs ):
@@ -82,9 +83,16 @@ def run(self, command, application):
8283 p .communicate ()
8384
8485
86+ class ExitHandler (object ):
87+ def run (self , command , application ):
88+ return EXIT_REQUESTED
89+
90+
8591class DotCommandHandler (object ):
8692 HANDLER_CLASSES = {
8793 'edit' : EditHandler ,
94+ 'exit' : ExitHandler ,
95+ 'quit' : ExitHandler ,
8896 }
8997
9098 def __init__ (self , output = sys .stdout , err = sys .stderr ):
@@ -109,7 +117,7 @@ def handle_cmd(self, command, application):
109117 else :
110118 # Note we expect the class to support no-arg
111119 # instantiation.
112- self .HANDLER_CLASSES [cmd_name ]().run (parts , application )
120+ return self .HANDLER_CLASSES [cmd_name ]().run (parts , application )
113121
114122 def _unknown_cmd (self , cmd_parts , application ):
115123 self ._err .write ("Unknown dot command: %s\n " % cmd_parts [0 ])
@@ -204,12 +212,12 @@ def run(self):
204212 self .save_config ()
205213 break
206214 else :
207- if text .strip () in ['quit' , 'exit' ]:
208- break
209215 if text .startswith ('.' ):
210216 # These are special commands. The only one supported for
211217 # 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
213221 else :
214222 if text .startswith ('!' ):
215223 # Then run the rest as a normally shell command.
0 commit comments