git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <stefanbeller@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] tag: Use OPT_BOOL instead of OPT_BOOLEAN to allow one action multiple times
Date: Tue, 30 Jul 2013 15:22:53 -0700	[thread overview]
Message-ID: <7vmwp3vgaq.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <51F82E83.30203@googlemail.com> (Stefan Beller's message of "Tue, 30 Jul 2013 23:22:11 +0200")

Stefan Beller <stefanbeller@googlemail.com> writes:

> Your approach seems more like what we really want, however I'd have
> some points:
>  * Is it a good idea to have so many different OPT_MODE or
>    OPTION_MODE defines? In my attempts I tried to reuse existing
>    OPTION_s to not pollute the parsing infrastructure with more
>    lines of code. ;)
>
>  * You can only have one OPTION_CMDMODE in one argv vector right?

That is not what I intended, at least.

	int one = 0, two = 0;
	struct option options[] = {
        OPT_CMDMODE('a', NULL, &one, N_("set one to a"), 'a'),
        OPT_CMDMODE('b', NULL, &one, N_("set one to b"), 'b'),
        OPT_CMDMODE('c', NULL, &two, N_("set two to c"), 'c'),
        OPT_CMDMODE('d', NULL, &two, N_("set two to d"), 'd'),
        OPT_END()
        }

should give you two independent sets of modes, one and two.

The only reason I needed to add an extra parameter to get_value()
was so that I can tell the former two and the latter two belong to
different groups, and that is done by looking at the address of the
variable.  In opt_command_mode_error(), opt->value == that->value
is used as a condition to see if the other option is possibly the
one that was used previously, which conflicted with us.

  reply	other threads:[~2013-07-30 22:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 18:00 [PATCH] tag: Use OPT_BOOL instead of OPT_BOOLEAN to allow one action multiple times Stefan Beller
2013-07-30 19:24 ` Junio C Hamano
2013-07-30 21:22   ` Stefan Beller
2013-07-30 22:22     ` Junio C Hamano [this message]
2013-07-30 21:28   ` Stefan Beller
2013-07-30 22:28     ` Junio C Hamano
2013-07-31 10:34       ` Stefan Beller
2013-07-31 23:10         ` Junio C Hamano
2013-08-17 15:01           ` Stefano Lattarini
2013-08-17 20:34             ` Jonathan Nieder
2013-08-18  9:27               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmwp3vgaq.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=stefanbeller@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).