Lines Matching refs:options
11 #include "parse-options.h"
345 static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options)
348 for (; options->type != OPTION_END; options++) {
349 if (options->short_name == *p->opt) {
351 return get_value(p, options, OPT_SHORT);
355 if (options->parent) {
356 options = options->parent;
364 const struct option *options)
374 for (; options->type != OPTION_END; options++) {
378 if (!options->long_name)
381 rest = skip_prefix(arg, options->long_name);
382 if (options->type == OPTION_ARGUMENT) {
386 return opterror(options, "takes no value", flags);
393 if (strstarts(options->long_name, "no-")) {
400 rest = skip_prefix(arg, options->long_name + 3);
406 if (strstarts(options->long_name + 3, arg)) {
412 if (!strncmp(options->long_name, arg, arg_end - arg)) {
426 abbrev_option = options;
439 rest = skip_prefix(arg + 3, options->long_name);
441 if (!rest && strstarts(options->long_name, arg + 3))
452 return get_value(p, options, flags);
468 if (options->parent) {
469 options = options->parent;
476 static void check_typos(const char *arg, const struct option *options)
486 for (; options->type != OPTION_END; options++) {
487 if (!options->long_name)
489 if (strstarts(options->long_name, arg)) {
515 const struct option *options,
537 return usage_with_options_internal(usagestr, options, 0, ctx);
539 switch (parse_short_opt(ctx, options)) {
541 return parse_options_usage(usagestr, options, arg, 1);
550 check_typos(arg, options);
553 return usage_with_options_internal(usagestr, options, 0, ctx);
555 switch (parse_short_opt(ctx, options)) {
557 return parse_options_usage(usagestr, options, arg, 1);
586 return usage_with_options_internal(usagestr, options, 1, ctx);
588 return usage_with_options_internal(usagestr, options, 0, ctx);
593 switch (parse_long_opt(ctx, arg, options)) {
595 return parse_options_usage(usagestr, options, arg, 0);
614 parse_options_usage(usagestr, options, arg, excl_short_opt);
618 parse_options_usage(NULL, options, &opt, 1);
620 parse_options_usage(NULL, options, ctx->excl_opt->long_name, 0);
632 int parse_options_subcommand(int argc, const char **argv, const struct option *options,
641 astrcatf(&buf, "%s %s [<options>] {", subcmd_config.exec_name, argv[0]);
654 switch (parse_options_step(&ctx, options, usagestr)) {
660 while (options->type != OPTION_END) {
661 if (options->long_name)
662 printf("--%s ", options->long_name);
663 options++;
680 usage_with_options(usagestr, options);
686 int parse_options(int argc, const char **argv, const struct option *options,
689 return parse_options_subcommand(argc, argv, options, NULL,