changeset 335:f69211e2c570

tweaks for sqlpython compatibility
author catherine@Drou
date Mon, 15 Feb 2010 17:45:52 -0500
parents 99dd71cb477a
children 8aa71e8f1064
files cmd2.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Fri Feb 12 23:29:19 2010 -0500
+++ b/cmd2.py	Mon Feb 15 17:45:52 2010 -0500
@@ -1256,6 +1256,11 @@
         result = runner.run(testcase)
         result.printErrors()
 
+    def run_commands_at_invocation(self, callargs):
+        for initial_command in callargs:
+            if self.onecmd(initial_command + '\n') == app._STOP_AND_EXIT:
+                return
+
     def cmdloop(self):
         parser = optparse.OptionParser()
         parser.add_option('-t', '--test', dest='test',
@@ -1265,11 +1270,7 @@
         if callopts.test:
             self.runTranscriptTests(callargs)
         else:
-            # hold onto the args and run .onecmd with them
-            # in sqlpython, first arg has implied \connect
-            for initial_command in callargs:
-                if self.onecmd(initial_command + '\n') == app._STOP_AND_EXIT:
-                    return            
+            self.run_commands_at_invocation(callargs)
             self._cmdloop()   
             
 class HistoryItem(str):