|
@@ -42,6 +42,8 @@ static int get_value(struct parse_opt_ctx_t *p,
|
|
return opterror(opt, "takes no value", flags);
|
|
return opterror(opt, "takes no value", flags);
|
|
if (unset && (opt->flags & PARSE_OPT_NONEG))
|
|
if (unset && (opt->flags & PARSE_OPT_NONEG))
|
|
return opterror(opt, "isn't available", flags);
|
|
return opterror(opt, "isn't available", flags);
|
|
|
|
+ if (opt->flags & PARSE_OPT_DISABLED)
|
|
|
|
+ return opterror(opt, "is not usable", flags);
|
|
|
|
|
|
if (!(flags & OPT_SHORT) && p->opt) {
|
|
if (!(flags & OPT_SHORT) && p->opt) {
|
|
switch (opt->type) {
|
|
switch (opt->type) {
|
|
@@ -509,6 +511,8 @@ static void print_option_help(const struct option *opts, int full)
|
|
}
|
|
}
|
|
if (!full && (opts->flags & PARSE_OPT_HIDDEN))
|
|
if (!full && (opts->flags & PARSE_OPT_HIDDEN))
|
|
return;
|
|
return;
|
|
|
|
+ if (opts->flags & PARSE_OPT_DISABLED)
|
|
|
|
+ return;
|
|
|
|
|
|
pos = fprintf(stderr, " ");
|
|
pos = fprintf(stderr, " ");
|
|
if (opts->short_name)
|
|
if (opts->short_name)
|
|
@@ -679,3 +683,16 @@ int parse_opt_verbosity_cb(const struct option *opt,
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void set_option_flag(struct option *opts, int shortopt, const char *longopt,
|
|
|
|
+ int flag)
|
|
|
|
+{
|
|
|
|
+ for (; opts->type != OPTION_END; opts++) {
|
|
|
|
+ if ((shortopt && opts->short_name == shortopt) ||
|
|
|
|
+ (opts->long_name && longopt &&
|
|
|
|
+ !strcmp(opts->long_name, longopt))) {
|
|
|
|
+ opts->flags |= flag;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|