Stefan Beller <[email protected]> writes:
> Here is just another idea:
> if (cmdmode == 'v')
> This may be hard to read, (What is 'v'? I cannot remember
> all the alphabet ;)) So maybe we could have an enum instead of
> the last parameter?
> OPT_CMDMODE( short, long, variable, description, enum)
I actually was thinking about going totally in the opposite
direction.
People who grew up with the old Unix tradition getopt(3) are used to
code like this:
while ((opt = getopt(ac, av, "abcde")) != -1) {
switch (opt) {
case 'a': perform_a(); break;
case 'b': perform_b(); break;
...
}
}
In other words, the "enum" is most convenient if it matches the
"short" option, so instead of having to repeat ourselves over and
over, like I did in that illustration patch for builtin/tag.c, e.g.
OPT_CMDMODE('d', "delete", &cmdmode, N_("delete tags"), 'd'),
OPT_CMDMODE('v', "verify", &cmdmode, N_("verify tags"), 'v'),
we could just do
#define OPT_CMDMODE(s, l, v, h) \
{ OPTION_CMDMODE, (s), (l), (v), NULL, \
(h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (s) }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html