Re: [PATCH PARSEOPT 1/4] parse-options new features.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 08, 2007 at 11:59:27PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@xxxxxxxxxx> writes:
> 
> > options flags:
> > ~~~~~~~~~~~~~
> >   PARSE_OPT_NONEG allow the caller to disallow the negated option to exists.
> 
> Good addition; writing OPT_CALLBACK was tricky without this when
> I tried to add --with=<commit> to git-branch.

  Well, you could do the same by hand, in the callback:

    if (unset)
        return error("go away with your --no-%s", opt->long_name);

  This is correct because only long options can be negated, and if the
callback returns -1 (< 0 actually IIRC, or maybe even !0) then
parse_options assume that you dealt with the error message, and will
just print out the usage and exit(129).

  So it merely offloads something that you could already do the very
same way _when using a callback_.

  It gets more interesting when you want to use an
OPT_INT/_STRING/whatever with an argument that isn't a callback and
don't want for some reason that --no-foo works. Before that change, you
needed a callback, now you don't :)
-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpdqgRMGKJ7W.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux