diff cmd2.py @ 328:7b2bca3951a7

locals_in_py
author cat@eee
date Fri, 12 Feb 2010 15:35:48 -0500
parents e9eea93c777c
children c69ad8418d39
line wrap: on
line diff
--- a/cmd2.py	Thu Feb 11 18:22:17 2010 -0500
+++ b/cmd2.py	Fri Feb 12 15:35:48 2010 -0500
@@ -402,6 +402,7 @@
     feedback_to_output = False          # Do include nonessentials in >, | output
     quiet = False                       # Do not suppress nonessential output
     debug = False
+    locals_in_py = False
     settable = stubbornDict('''
         prompt
         colors                Colorized output (*nix only)
@@ -1030,13 +1031,16 @@
             interp = InteractiveInterpreter(locals=self.pystate)
             interp.runcode(arg)
         else:
-            interp = MyInteractiveConsole(locals=self.pystate)
+            localvars = (self.locals_in_py and self.pystate) or {}
+            interp = MyInteractiveConsole(locals=localvars)
             def quit():
+                'blah'
                 raise EmbeddedConsoleExit
             def onecmd(arg):
                 return self.onecmd(arg + '\n')
             self.pystate['quit'] = quit
             self.pystate['exit'] = quit
+            self.pystate['cmd'] = onecmd
             try:
                 cprt = 'Type "help", "copyright", "credits" or "license" for more information.'        
                 keepstate = Statekeeper(sys, ('stdin','stdout'))