return 0;
}
if (!rest) {
- if (strstarts(options->long_name, "no-")) {
+ if (strstarts(options->long_name, "no-") &&
+ !(options->flags & PARSE_OPT_NOAUTONEG)) {
/*
* The long name itself starts with "no-", so
* accept the option without "no-" so that users
continue;
}
/* negated and abbreviated very much? */
- if (strstarts("no-", arg)) {
+ if (strstarts("no-", arg) && !(options->flags & PARSE_OPT_NOAUTONEG)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
/* negated? */
- if (strncmp(arg, "no-", 3))
+ if (strncmp(arg, "no-", 3) || (options->flags & PARSE_OPT_NOAUTONEG))
continue;
flags |= OPT_UNSET;
rest = skip_prefix(arg + 3, options->long_name);
if (strstarts(opts->long_name, optstr))
print_option_help(opts, 0);
if (strstarts("no-", optstr) &&
- strstarts(opts->long_name, optstr + 3))
+ strstarts(opts->long_name, optstr + 3) &&
+ !(opts->flags & PARSE_OPT_NOAUTONEG))
print_option_help(opts, 0);
}
PARSE_OPT_NOEMPTY = 128,
PARSE_OPT_NOBUILD = 256,
PARSE_OPT_CANSKIP = 512,
+ PARSE_OPT_NOAUTONEG = 1024,
};
struct option;
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
#define OPT_CALLBACK(s, l, v, a, h, f) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = (a), .help = (h), .callback = (f) }
+#define OPT_CALLBACK_FLAG(s, l, v, a, h, f, fl) \
+ { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = (a), .help = (h), .callback = (f), .flags = (fl) }
#define OPT_CALLBACK_SET(s, l, v, os, a, h, f) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = (a), .help = (h), .callback = (f), .set = check_vtype(os, bool *)}
#define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \