On 04/29/2013 11:27 AM, Ján Tomko wrote:
For long options, print:
* the option as specified by the user if it's unknown
* the cannoncial long option if its argument is not
s/cannonical/canonical/
a number (and should be)
And for missing arguments, print both the short and
the long option name.
(Doing only one of those would require either parsing
argv ourselves or let getopt print the errors, since
we can't tell long and short options apart by optopt
or longindex)
https://bugzilla.redhat.com/show_bug.cgi?id=949373
Listing some before-and-after in the commit message would be very
helpful. Here's what I tried:
Unknown option:
Before:
$ virsh -x
error: unsupported option '-x'. See --help.
$ virsh --x
error: unsupported option '-
$ virsh -rx
error: unsupported option '-x'. See --help.
After:
$ tools/virsh -x
error: unsupported option '-x'. See --help.
$ tools/virsh --x
error: unsupported option '--x'. See --help.
$ tools/virsh -rx
error: unsupported option '-x'. See --help.
No worse behavior, and definite improvement on the unknown long option.
Incorrect argument:
Before:
$ virsh --d=a
error: option -d takes a numeric argument
$ virsh --deb=a
error: option -d takes a numeric argument
After:
$ tools/virsh -da
error: option -d takes a numeric argument
$ tools/virsh --deb=a
error: option --debug takes a numeric argument
Much nicer on the long option :)
Missing argument:
Before:
$ virsh -d
error: option '-d' requires an argument
$ virsh --deb
error: option '-d' requires an argument
After:
$ tools/virsh -d
error: option '-d'/'--debug' requires an argument
$ tools/virsh --deb
error: option '-d'/'--debug' requires an argument
A bit more verbose, but now it is obvious when a long option was typed,
rather than making you figure out what short option matches your long
option. And I agree that improving it would require reimplementing too
much of getopt_long, so I can live with it.
ACK. Reasonable for 1.0.5
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org