Mercurial > python-cmd2
diff cmd2.py @ 43:e03a8c03ac37
command-line args working
author | catherine@cordelia |
---|---|
date | Sun, 25 May 2008 05:22:27 -0400 |
parents | b3200c6e5763 |
children | b66372883bb4 |
line wrap: on
line diff
--- a/cmd2.py Sat May 24 20:30:33 2008 -0400 +++ b/cmd2.py Sun May 25 05:22:27 2008 -0400 @@ -125,9 +125,6 @@ raise OSError, pastebufferr % ('xclip', 'On Debian/Ubuntu, install with "sudo apt-get install xclip"') setPasteBuffer = getPasteBuffer -class ExitException(Exception): - pass - class Cmd(cmd.Cmd): caseInsensitive = True multilineCommands = [] @@ -340,7 +337,7 @@ readline.set_completer(self.old_completer) except ImportError: pass - return stop + return stop def do_EOF(self, arg): return True @@ -375,7 +372,7 @@ self.stdout.write('%s: %s\n' % (param, str(getattr(self, param)))) def do_quit(self, arg): - raise ExitException + return self._STOP_AND_EXIT do_exit = do_quit do_q = do_quit @@ -507,12 +504,11 @@ self.use_rawinput = False self.prompt = self.continuationPrompt = '' stop = self.cmdloop() - # but how to detect whether to exit totally? self.stdin.close() keepstate.restore() self.lastcmd = '' - return (stop == self._STOP_AND_EXIT) - + return (stop == self._STOP_AND_EXIT) and self._STOP_AND_EXIT + def do_run(self, arg): """run [arg]: re-runs an earlier command