Optik help/metavar delimiters (SF #815264)
Greg Ward <[email protected]> Sat, 22 May 2004 13:44:52 -0400
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
I've just been looking at SF bug #815264 (which is really a feature
request); here's the text of the "bug":
"""
For options with arguments (--option=ARGUMENT), the syntax -oARGUMENT is
valid. However, it's difficult to read in the help output of commands.
Displaying the (optional) space in help output would improve
readability. For example it would look like this:
-o ARGUMENT
(took me awhile to figure out that -oARGUMENT wasn't
equivalent to -o -A -R ... but that's a feature... )
"""
After a bit of fiddling, I totally agree -- "-f FILE" looks better than
"-fFILE". So I think this should be the default. I also think it
should be customizable. Here's the API I propose:
# First get my hands on a HelpFormatter, either by creating my
# own or fetching the one OptionParser creates in its constructor.
formatter = ...
# Fiddle with the option/metavar delimiters.
formatter.set_short_opt_delimiter(" ") # proposed Optik 1.5 behaviour
formatter.set_short_opt_delimiter("") # revert to pre-1.5 behaviour
formatter.set_long_opt_delimiter("=") # Optik 1.4 and 1.5 behaviour
formatter.set_long_opt_delimiter(" ") # alternate syntax if you prefer
With this, there are four basic styles for option help:
1) -uUSER, --user=USER show only revisions by USER
2) -u USER, --user=USER show only revisions by USER
3) -uUSER, --user USER show only revisions by USER
4) -u USER, --user USER show only revisions by USER
#1 is all you get with Optik 1.4.1 and earlier.
#2 is my proposed new default for Optik 1.5.
#3 and #4 are available if you want them.
If you pass an invalid delimiter to either set_short_opt_delimiter() or
set_long_opt_delimiter(), it raises ValueError. You can't specify an
arbitrary delimiter, because Optik only supports these four syntaxes!
I'll attach a patch that implements this. (Err, this doesn't update the
test suite.) Comments welcome...
Greg
--
Greg Ward <[email protected]> http://www.gerg.ca/
Any priest or shaman must be presumed guilty until proven innocent.
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click