#12 Add 'preserve_whitespace' and 'SUPPRESS_METAVAR'

Ben Blank

This is a patch against the Optik 1.5 release which
adds two minor -- but very helpful -- features to

First, it adds "preserve_whitespace" to HelpFormatter's
__init__(). It's meaning is opposite that of the
"replace_whitespace" in textwrap functions. (The
reversed name was chosen because the default is
preserve_whitespace=False, for backwards compatibility.
It would be trivial to reverse it back to
replace_whitespace by tweaking only the three __init__
functions in help.py, as that's where the reversal occurs.)

Second (and completely unrelated), HelpFormatter's
format_option_strings() suppresses an Option's metavar
if option.metavar=SUPPRESS_METAVAR. I've found this to
be useful in conjuction with complex callbacks or when
nargs > 1 (reduces clutter).


  • Ben Blank

    Ben Blank - 2005-08-26

    preserve_whitespace/SUPPRESS_METAVAR patch

  • Greg Ward

    Greg Ward - 2005-10-27
    • assigned_to: nobody --> gward
  • Greg Ward

    Greg Ward - 2005-10-27

    Logged In: YES

    Looks harmless enough ... but could you supply a short,
    simple script that uses these features? I need to
    understand your rationale before I can accept the patch.
    And an example would be helpful for documentation too.

    Also, does this patch fully address what you asked for in
    feature request #1055954?

  • Ben Blank

    Ben Blank - 2005-11-21

    Logged In: YES

    Sorry for the delay -- the box I cooked this up on (and
    which houses the script which uses it) is offline at the
    moment. I'll pull the example for you as soon as I can.

    As for the feature request, it's not mine, but the
    preserve_whitespace option should, indeed, allow the hard
    newlines that user wanted.

  • Greg Ward

    Greg Ward - 2006-06-13

    Logged In: YES

    Oof, 7 months with no action on this. Are you still
    interested? If so, can you add test and documentation
    patches? (If you don't feel up to writing docs, that's OK,
    but I really must insist on unit tests for every new
    feature. That's the best way for me to understand your


Log in to post a comment.