[Libguestfs] [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
Richard W.M. Jones
rjones at redhat.com
Mon Jul 18 13:43:03 UTC 2016
On Mon, Jul 18, 2016 at 03:21:31PM +0200, Pino Toscano wrote:
> On Monday, 18 July 2016 11:46:46 CEST Richard W.M. Jones wrote:
> > ---
>
> Note that this changes the way -foo options are handled: this basically
> makes them as --foo, but still working as -foo because getopt_long_only
> is used. IMHO either add a new M".." ([M]edium or [T]runcated or
> [D]ash or ...), or turn S to get a string instead.
Do you mean only for the 'virt-v2v --help' output? I don't think
there is any other place in the code where the M option would be
handled differently from the L option.
> > - let validate_key key =
> > - if String.length key == 0 || key == "-" || key == "--"
> > - || key.[0] != '-' then
> > - invalid_arg (sprintf "invalid option key: '%s'" key)
> > + let validate_key = function
> > + | L"" -> invalid_arg "Getopt spec: invalid empty long option"
> > + | L"help" -> invalid_arg "Getopt spec: should not have L\"help\""
>
> Theoretically both Arg and the current Getopt allow applications to
> provide an own handler for --help, instead of the built-in one.
Sure, but I don't think that's a good idea :-)
> > + | L s when String.contains s '_' ->
> > + invalid_arg (sprintf "Getopt spec: L%S should not contain '_'"
> > + s)
>
> Why this limitation?
I guess we don't need this limitation. It's there to catch accidental
underscores. If we actually have to use underscore parameters then we
can remove this later.
> IMHO it'd be better to sort the specs at this point, like done before;
> otherwise, --help (and potentially any non-hidden built-in option added
> here) will be shown only at the end of the other specs.
At the beginning of the list, and it was deliberate. However it's
just a matter of preference, and the options could be sorted later.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
More information about the Libguestfs
mailing list