comparison cmd2.py @ 34:d3b2f9c6e536

run
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Fri, 21 Dec 2007 16:01:52 -0500
parents 061f40299ed5
children e2a5cdba3113
comparison
equal deleted inserted replaced
33:061f40299ed5 34:d3b2f9c6e536
6 Special-character shortcut commands 6 Special-character shortcut commands
7 Load commands from file 7 Load commands from file
8 Settable environment parameters 8 Settable environment parameters
9 9
10 still to do: 10 still to do:
11 edit 11 edit spits eof
12 run 12 run
13 > 13 >
14 """ 14 """
15 import cmd, re, os, sys 15 import cmd, re, os, sys
16 16
284 self.prompt = self.continuationPrompt = '' 284 self.prompt = self.continuationPrompt = ''
285 self.cmdloop() 285 self.cmdloop()
286 self.stdin.close() 286 self.stdin.close()
287 keepstate.restore() 287 keepstate.restore()
288 self.lastcmd = '' 288 self.lastcmd = ''
289
290 def do_run(self, arg):
291 """run [arg]: re-runs an earlier command
292
293 no arg -> run most recent command
294 arg is integer -> run one history item, by index
295 arg is string -> run most recent command by string search
296 arg is /enclosed in forward-slashes/ -> run most recent by regex
297 """
298 'run [N]: runs the SQL that was run N commands ago'
299 runme = self.last_matching(arg)
300 print runme
301 if runme:
302 runme = self.precmd(runme)
303 stop = self.onecmd(runme)
304 stop = self.postcmd(stop, runme)
305 do_r = do_run
289 306
290 class HistoryItem(str): 307 class HistoryItem(str):
291 def __init__(self, instr): 308 def __init__(self, instr):
292 str.__init__(self, instr) 309 str.__init__(self, instr)
293 self.lowercase = self.lower() 310 self.lowercase = self.lower()