Lines Matching defs:options

11 #include "parse-options.h"
382 static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options)
385 for (; options->type != OPTION_END; options++) {
386 if (options->short_name == *p->opt) {
388 return get_value(p, options, OPT_SHORT);
392 if (options->parent) {
393 options = options->parent;
401 const struct option *options)
411 for (; options->type != OPTION_END; options++) {
415 if (!options->long_name)
418 rest = skip_prefix(arg, options->long_name);
419 if (options->type == OPTION_ARGUMENT) {
423 return opterror(options, "takes no value", flags);
430 if (strstarts(options->long_name, "no-") &&
431 !(options->flags & PARSE_OPT_NOAUTONEG)) {
438 rest = skip_prefix(arg, options->long_name + 3);
444 if (strstarts(options->long_name + 3, arg)) {
450 if (!strncmp(options->long_name, arg, arg_end - arg)) {
464 abbrev_option = options;
469 if (strstarts("no-", arg) && !(options->flags & PARSE_OPT_NOAUTONEG)) {
474 if (strncmp(arg, "no-", 3) || (options->flags & PARSE_OPT_NOAUTONEG))
477 rest = skip_prefix(arg + 3, options->long_name);
479 if (!rest && strstarts(options->long_name, arg + 3))
490 return get_value(p, options, flags);
506 if (options->parent) {
507 options = options->parent;
514 static void check_typos(const char *arg, const struct option *options)
524 for (; options->type != OPTION_END; options++) {
525 if (!options->long_name)
527 if (strstarts(options->long_name, arg)) {
553 const struct option *options,
575 return usage_with_options_internal(usagestr, options, 0, ctx);
577 switch (parse_short_opt(ctx, options)) {
579 return parse_options_usage(usagestr, options, arg, 1);
588 check_typos(arg, options);
591 return usage_with_options_internal(usagestr, options, 0, ctx);
593 switch (parse_short_opt(ctx, options)) {
595 return parse_options_usage(usagestr, options, arg, 1);
624 return usage_with_options_internal(usagestr, options, 1, ctx);
626 return usage_with_options_internal(usagestr, options, 0, ctx);
631 switch (parse_long_opt(ctx, arg, options)) {
633 return parse_options_usage(usagestr, options, arg, 0);
652 parse_options_usage(usagestr, options, arg, excl_short_opt);
656 parse_options_usage(NULL, options, &opt, 1);
658 parse_options_usage(NULL, options, ctx->excl_opt->long_name, 0);
670 int parse_options_subcommand(int argc, const char **argv, const struct option *options,
679 astrcatf(&buf, "%s %s [<options>] {", subcmd_config.exec_name, argv[0]);
692 switch (parse_options_step(&ctx, options, usagestr)) {
698 while (options->type != OPTION_END) {
699 if (options->long_name)
700 printf("--%s ", options->long_name);
701 options++;
718 usage_with_options(usagestr, options);
724 int parse_options(int argc, const char **argv, const struct option *options,
727 return parse_options_subcommand(argc, argv, options, NULL,
851 /* flatten the options that have parents */
857 * the length is given by the number of options plus a null