Mercurial > python-cmd2
comparison cmd2.py @ 335:f69211e2c570
tweaks for sqlpython compatibility
author | catherine@Drou |
---|---|
date | Mon, 15 Feb 2010 17:45:52 -0500 |
parents | 99dd71cb477a |
children | 8aa71e8f1064 |
comparison
equal
deleted
inserted
replaced
334:99dd71cb477a | 335:f69211e2c570 |
---|---|
1254 testcase = TestMyAppCase() | 1254 testcase = TestMyAppCase() |
1255 runner = unittest.TextTestRunner() | 1255 runner = unittest.TextTestRunner() |
1256 result = runner.run(testcase) | 1256 result = runner.run(testcase) |
1257 result.printErrors() | 1257 result.printErrors() |
1258 | 1258 |
1259 def run_commands_at_invocation(self, callargs): | |
1260 for initial_command in callargs: | |
1261 if self.onecmd(initial_command + '\n') == app._STOP_AND_EXIT: | |
1262 return | |
1263 | |
1259 def cmdloop(self): | 1264 def cmdloop(self): |
1260 parser = optparse.OptionParser() | 1265 parser = optparse.OptionParser() |
1261 parser.add_option('-t', '--test', dest='test', | 1266 parser.add_option('-t', '--test', dest='test', |
1262 action="store_true", | 1267 action="store_true", |
1263 help='Test against transcript(s) in FILE (wildcards OK)') | 1268 help='Test against transcript(s) in FILE (wildcards OK)') |
1264 (callopts, callargs) = parser.parse_args() | 1269 (callopts, callargs) = parser.parse_args() |
1265 if callopts.test: | 1270 if callopts.test: |
1266 self.runTranscriptTests(callargs) | 1271 self.runTranscriptTests(callargs) |
1267 else: | 1272 else: |
1268 # hold onto the args and run .onecmd with them | 1273 self.run_commands_at_invocation(callargs) |
1269 # in sqlpython, first arg has implied \connect | |
1270 for initial_command in callargs: | |
1271 if self.onecmd(initial_command + '\n') == app._STOP_AND_EXIT: | |
1272 return | |
1273 self._cmdloop() | 1274 self._cmdloop() |
1274 | 1275 |
1275 class HistoryItem(str): | 1276 class HistoryItem(str): |
1276 listformat = '-------------------------[%d]\n%s\n' | 1277 listformat = '-------------------------[%d]\n%s\n' |
1277 def __init__(self, instr): | 1278 def __init__(self, instr): |