[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6125: [PATCH] Fix indent of --help and --version
From: |
Eric Blake |
Subject: |
bug#6125: [PATCH] Fix indent of --help and --version |
Date: |
Thu, 06 May 2010 10:50:22 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Mnenhy/0.8.2 Thunderbird/3.0.4 |
On 05/06/2010 02:00 AM, Zhang Sen wrote:
> Hi,
>
>>From the several commands I tried, HELP_OPTION_DESCRIPTION and
> VERSION_OPTION_DESCRIPTION don't align well with others in the Usage.
>
> $ cat --help
> -u (ignored)
> -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
> --help display this help and exit
> --version output version information and exit
First, thanks for taking the time to contribute, and especially for
including a patch. Too many people make requests with no code to back
it up. However, I'm hesitant to apply your patch.
I see --help output as having three columns - short options, long
options, and description. Many options have both short and long (in
your example, -v and --show-nonprinting), some have short only (-u), and
some have long only (--help). I see nothing wrong with the alignment of
the first two columns in the above example, but agree that the third
column could be better aligned.
I can see your view of --help output having only two columns, and that
the leading - should always be aligned, but I'm not sure I agree with it.
>
> Here is a trivial patch to make the printing of --help/--version be
> consistent with other options from Usage.
>
> $ cat --help
> -u (ignored)
> -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
> --help display this help and exit
> --version output version information and exit
This is a step backwards in my mind. It mixes column 1 and 2, rather
than keeping long options in column 2.
>
> Of course the second column is still broken, but I think that's beyond
> this simple patch.
An even nicer fix would be to write a word-wrapping algorithm, that
takes $COLUMNS into account, and formats all of the columns (short
option, long option, and description) appropriately given the current
screen width and maximum length of the long options column. But that
means a large rewrite of all of the usage() functions to call this new
formatting system. It does sound like a nice project, but it's not my
highest priority.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature