Mercurial > sqlpython
comparison cmd2.py @ 39:5d29e6a21c6f
ready to package cmd2
author | devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil |
---|---|
date | Thu, 03 Jan 2008 13:48:50 -0500 |
parents | ed1f390c142d |
children |
comparison
equal
deleted
inserted
replaced
38:ed1f390c142d | 39:5d29e6a21c6f |
---|---|
10 Special-character shortcut commands (beyond cmd's "@" and "!") | 10 Special-character shortcut commands (beyond cmd's "@" and "!") |
11 Settable environment parameters | 11 Settable environment parameters |
12 | 12 |
13 todo: | 13 todo: |
14 edited commands end with "EOF". Hmm. | 14 edited commands end with "EOF". Hmm. |
15 flags | 15 example of flag usage |
16 > | 16 > to dump to file |
17 """ | 17 """ |
18 import cmd, re, os, sys | 18 import cmd, re, os, sys |
19 import flagReader | |
19 | 20 |
20 class Cmd(cmd.Cmd): | 21 class Cmd(cmd.Cmd): |
21 caseInsensitive = True | 22 caseInsensitive = True |
22 multilineCommands = [] | 23 multilineCommands = [] |
23 continuationPrompt = '> ' | 24 continuationPrompt = '> ' |
43 }) | 44 }) |
44 | 45 |
45 def __init__(self, *args, **kwargs): | 46 def __init__(self, *args, **kwargs): |
46 cmd.Cmd.__init__(self, *args, **kwargs) | 47 cmd.Cmd.__init__(self, *args, **kwargs) |
47 self.history = History() | 48 self.history = History() |
49 | |
50 def do_shortcuts(self, args): | |
51 """Lists single-key shortcuts available.""" | |
52 result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in self.shortcuts.items()) | |
53 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) | |
48 | 54 |
49 def onecmd(self, line): | 55 def onecmd(self, line): |
50 """Interpret the argument as though it had been typed in response | 56 """Interpret the argument as though it had been typed in response |
51 to the prompt. | 57 to the prompt. |
52 | 58 |