changeset 356:d275d3beceff

fix usage help name-stripping bug
author catherine@dellzilla
date Wed, 17 Feb 2010 14:32:04 -0500
parents 5972ae04515e
children ce4448ca4088
files cmd2.py docs/pycon2010/pirate7.py docs/pycon2010/pirate8.py docs/pycon2010/pycon2010.rst docs/pycon2010/script.txt docs/pycon2010/transcript.txt
diffstat 6 files changed, 37 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Wed Feb 17 12:32:49 2010 -0500
+++ b/cmd2.py	Wed Feb 17 14:32:04 2010 -0500
@@ -120,7 +120,7 @@
         optionParser = OptionParser()
         for opt in option_list:
             optionParser.add_option(opt)
-        optionParser.set_usage("%s [options] arg" % func.__name__.strip('do_'))
+        optionParser.set_usage("%s [options] arg" % func.__name__[3:])
         optionParser._func = func
         def new_func(instance, arg):
             try:
--- a/docs/pycon2010/pirate7.py	Wed Feb 17 12:32:49 2010 -0500
+++ b/docs/pycon2010/pirate7.py	Wed Feb 17 14:32:04 2010 -0500
@@ -35,8 +35,11 @@
     default_to_shell = True
     multilineCommands = ['sing']
     terminators = Cmd.terminators + ['...']
+    songcolor = 'blue'
+    settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)'
+    Cmd.shortcuts.update({'~': 'sing'})
     def do_sing(self, arg):
-        print(self.colorize(arg, 'blue'))
+        print(self.colorize(arg, self.songcolor))
 
 pirate = Pirate()
 pirate.cmdloop()
\ No newline at end of file
--- a/docs/pycon2010/pirate8.py	Wed Feb 17 12:32:49 2010 -0500
+++ b/docs/pycon2010/pirate8.py	Wed Feb 17 14:32:04 2010 -0500
@@ -35,8 +35,11 @@
     default_to_shell = True
     multilineCommands = ['sing']
     terminators = Cmd.terminators + ['...']
+    songcolor = 'blue'
+    settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)'
+    Cmd.shortcuts.update({'~': 'sing'})
     def do_sing(self, arg):
-        print(self.colorize(arg, 'blue'))
+        print(self.colorize(arg, self.songcolor))
     @options([make_option('--ho', type='int', help="How often to chant 'ho'", default=2),
               make_option('-c', '--commas', action="store_true", help="Interspers commas")])
     def do_yo(self, arg, opts):
--- a/docs/pycon2010/pycon2010.rst	Wed Feb 17 12:32:49 2010 -0500
+++ b/docs/pycon2010/pycon2010.rst	Wed Feb 17 14:32:04 2010 -0500
@@ -242,14 +242,6 @@
     * Shortcuts
     * Multiline commands
     * Environment variables
-    
-Now how much would you pay?
-===========================
-
-    * options / flags
-    * Quiet (suppress feedback) 
-    * BASH-style ``select``
-    * Parsing: terminators, suffixes
 
 Minor changes: pirate7.py
 =========================    
@@ -259,8 +251,19 @@
     default_to_shell = True
     multilineCommands = ['sing']
     terminators = Cmd.terminators + ['...']
+    songcolor = 'blue'
+    settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)'
+    Cmd.shortcuts.update({'~': 'sing'})
     def do_sing(self, arg):
-        print(self.colorize(arg, 'blue'))
+        print(self.colorize(arg, self.songcolor))
+    
+Now how much would you pay?
+===========================
+
+    * options / flags
+    * Quiet (suppress feedback) 
+    * BASH-style ``select``
+    * Parsing: terminators, suffixes
         
 Options: pirate8.py
 ===================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/pycon2010/script.txt	Wed Feb 17 14:32:04 2010 -0500
@@ -0,0 +1,4 @@
+loot
+loot
+drink 3
+drink chardonnay
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/pycon2010/transcript.txt	Wed Feb 17 14:32:04 2010 -0500
@@ -0,0 +1,12 @@
+arrr> loot
+Now we gots 4 doubloons
+arrr> loot
+Now we gots 5 doubloons
+arrr> drink 3
+Now we gots 2 doubloons
+arrr> drink chardonnay
+What's "chardonnay"?  I'll take rrrum.
+Now we gots 1 doubloons
+arrr> quit
+Quiterrr!
+