]> xenbits.xensource.com Git - libvirt.git/commit
virsh: fix incorrect argument errors for long options
authorJán Tomko <jtomko@redhat.com>
Mon, 29 Apr 2013 17:12:17 +0000 (19:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 30 Apr 2013 08:23:44 +0000 (10:23 +0200)
commit53531e16bf7cfe4fe20a4fe132f8199dcd474245
treef216c8b32cbbc46980a04cba0ab15a237b097440
parenteca3fdf7385a0d38dff33d6e40f01f81c8dea025
virsh: fix incorrect argument errors for long options

For long options, print:
* the option as specified by the user if it's unknown
* the canonical long option if its argument is not
  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

Unsupported long option:

$ virsh --pm
Before:
error: unsupported option '-
After:
error: unsupported option '--pm'. See --help.

Missing parameter:

$ virsh --deb
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

$ virsh -rd
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

Non-numeric parameter:

$ virsh --deb duck
Before:
error: option -d takes a numeric argument
After:
error: option --debug takes a numeric argument
tools/virsh.c