RegistryOption does not show possible values with value_switches=False

Adeodato Simó dato at net.com.org.es
Mon Nov 26 21:05:19 GMT 2007


* Adeodato Simó [Sun, 25 Nov 2007 20:09:56 +0100]:

> I tried to implement this, so that tags' --sort option gets useable
> help, but it doesn't seem possible to do it right away, because
> optparse.OptionParser inconditionally wraps the help for an option as a
> single paragraph, even if there are newlines in it.

> OptionParser accepts a formatter kwarg, and it will use it instead of
> the standard IndentedHelpFormatter, but it would still mean duplicating
> most of optparser.HelpFormatter.format_option().

> Other option would be to somehow place the documentation for possible
> values in a separate paragraph, like it happens with value_switches=True.
> I guess for that one could subclass OptionParser. I may try this approach 
> during the upcoming week.

> CCing Aaron in case he has any comments.

Or you can provide a custom formatter that, instead of duplicating code
from the standard formatter, gets in the verge of evil and substitutes
textwrap.wrap by a function that will respect newlines. I have no idea
if this would be allowed in the Bazaar codebase, but a patch without
tests is attached.

Output is like:

% bzr help tags
Purpose: List tags.
Usage:   bzr tags

Options:
  --sort=ARG            Sort tags by different criteria. Posible values:
                          - alpha: Sort tags lexicographically (default).
                          - time: Sort tags chronologically.
  -v, --verbose         Display more information.
  ...

Cheers,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
            Listening to: Joaquín Sabina - Una canción para la Magdalena
-------------- next part --------------
A non-text attachment was scrubbed...
Name: document_registry_option_without_value_switches.diff
Type: text/x-diff
Size: 1828 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071126/22dc597a/attachment.bin 


More information about the bazaar mailing list