def cmdloop(self): try: Cmd.cmdloop(self) except KeyboardInterrupt as e: self.__key_interrupt = self.__key_interrupt + 1 if self.__key_interrupt > 1: print('^C') self.do_exit(self) else: print('Press Ctrl-C again to exit.') self.cmdloop()
def run_cmd2_app(app: cmd2.Cmd) -> None: """ Run a cmd2 App as CLI or shell. Handle exit code return value, too. """ if len(sys.argv) > 1: # CLI usage => run only one command and then exit app.onecmd_plus_hooks(line=argv2str(sys.argv[1:])) exit_code = app.exit_code else: exit_code = app.cmdloop() sys.exit(exit_code)
def cmdloop(self, intro=None): if RehashUI.user_quit: raise Quit() else: Cmd.cmdloop(self, intro)