[PATCH]: Optional explanation for options

Magnus Therning magnus at therning.org
Wed Sep 7 09:04:07 BST 2005


The following patch makes it possible to add explanations to options for
commands. E.g.

class cmd_my_command(Command):
    ...
    takes_options = [('revision', 'Retrieve particular revision')]
    ...

I think it'd be handy for command line completion...

/M

*** modified file 'bzrlib/help.py'
--- bzrlib/help.py 
+++ bzrlib/help.py 
@@ -51,7 +51,7 @@
 """
 
 
-import sys
+import sys, types
 
 
 def help(topic=None, outfile = None):
@@ -127,11 +127,18 @@
 
     outfile.write('\noptions:\n')
     for on in options:
+        if isinstance(on, types.TupleType):
+            expl = on[1]
+            on = on[0]
+        else:
+            expl = ''
         l = '    --' + on
         for shortname, longname in SHORT_OPTIONS.items():
             if longname == on:
                 l += ', -' + shortname
                 break
+        if expl:
+            l += (30 - len(l)) * ' ' + expl
         outfile.write(l + '\n')

-- 
Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
magnus at therning.org
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

'Almost never' ALWAYS arrives sooner than you expect.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050907/9e3ed248/attachment.pgp 


More information about the bazaar mailing list