git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] tag: Use OPT_BOOL instead of OPT_BOOLEAN to allow one action multiple times

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2013, 22:22 UTC
Message-ID
<7vmwp3vgaq.fsf@alter.siamese.dyndns.org>
In-Reply-To
<51F82E83.30203@googlemail.com>
Stefan Beller <stefanbeller@googlemail.com> writes:
Show 8 quoted lines
> 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.

Previous: Stefan BellerNext: Stefan Beller
Message 4 of 11 in “tag: Use OPT_BOOL instead of OPT_BOOLEAN to allow one action multiple times”
  1. tag: Use OPT_BOOL instead of OPT_BOOLEAN to allow one action multiple timesStefan Beller, Jul 30, 2013
  2. Junio C HamanoJul 30, 2013
  3. Stefan BellerJul 30, 2013
  4. Junio C HamanoJul 30, 2013
  5. Stefan BellerJul 30, 2013
  6. Junio C HamanoJul 30, 2013
  7. Stefan BellerJul 31, 2013
  8. Junio C HamanoJul 31, 2013
  9. Stefano LattariniAug 17, 2013
  10. Jonathan NiederAug 17, 2013
  11. Junio C HamanoAug 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.