Lines Matching refs:opts
696 static void print_option_help(const struct option *opts, int full) in print_option_help() argument
701 if (opts->type == OPTION_GROUP) { in print_option_help()
703 if (*opts->help) in print_option_help()
704 fprintf(stderr, "%s\n", opts->help); in print_option_help()
707 if (!full && (opts->flags & PARSE_OPT_HIDDEN)) in print_option_help()
709 if (opts->flags & PARSE_OPT_DISABLED) in print_option_help()
713 if (opts->short_name) in print_option_help()
714 pos += fprintf(stderr, "-%c", opts->short_name); in print_option_help()
718 if (opts->long_name && opts->short_name) in print_option_help()
720 if (opts->long_name) in print_option_help()
721 pos += fprintf(stderr, "--%s", opts->long_name); in print_option_help()
723 switch (opts->type) { in print_option_help()
731 if (opts->flags & PARSE_OPT_OPTARG) in print_option_help()
732 if (opts->long_name) in print_option_help()
740 if (opts->flags & PARSE_OPT_NOARG) in print_option_help()
744 if (opts->argh) { in print_option_help()
745 if (opts->flags & PARSE_OPT_OPTARG) in print_option_help()
746 if (opts->long_name) in print_option_help()
747 pos += fprintf(stderr, "[=<%s>]", opts->argh); in print_option_help()
749 pos += fprintf(stderr, "[<%s>]", opts->argh); in print_option_help()
751 pos += fprintf(stderr, " <%s>", opts->argh); in print_option_help()
753 if (opts->flags & PARSE_OPT_OPTARG) in print_option_help()
754 if (opts->long_name) in print_option_help()
779 fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help); in print_option_help()
780 if (opts->flags & PARSE_OPT_NOBUILD) in print_option_help()
783 opts->build_opt); in print_option_help()
807 static struct option *options__order(const struct option *opts) in options__order() argument
810 const struct option *o = opts; in options__order()
813 for (o = opts; o->type != OPTION_END; o++) in options__order()
820 memcpy(ordered, opts, len); in options__order()
859 const struct option *opts, int full, in usage_with_options_internal() argument
884 if (opts->type != OPTION_GROUP) in usage_with_options_internal()
887 ordered = options__order(opts); in usage_with_options_internal()
889 opts = ordered; in usage_with_options_internal()
891 for ( ; opts->type != OPTION_END; opts++) { in usage_with_options_internal()
892 if (ctx && ctx->argc > 1 && !option__in_argv(opts, ctx)) in usage_with_options_internal()
894 print_option_help(opts, full); in usage_with_options_internal()
905 const struct option *opts) in usage_with_options() argument
907 usage_with_options_internal(usagestr, opts, 0, NULL); in usage_with_options()
912 const struct option *opts, const char *fmt, ...) in usage_with_options_msg() argument
924 usage_with_options_internal(usagestr, opts, 0, NULL); in usage_with_options_msg()
929 const struct option *opts, in parse_options_usage() argument
947 for ( ; opts->type != OPTION_END; opts++) { in parse_options_usage()
949 if (opts->short_name == *optstr) { in parse_options_usage()
950 print_option_help(opts, 0); in parse_options_usage()
956 if (opts->long_name == NULL) in parse_options_usage()
959 if (strstarts(opts->long_name, optstr)) in parse_options_usage()
960 print_option_help(opts, 0); in parse_options_usage()
962 strstarts(opts->long_name, optstr + 3)) in parse_options_usage()
963 print_option_help(opts, 0); in parse_options_usage()
994 find_option(struct option *opts, int shortopt, const char *longopt) in find_option() argument
996 for (; opts->type != OPTION_END; opts++) { in find_option()
997 if ((shortopt && opts->short_name == shortopt) || in find_option()
998 (opts->long_name && longopt && in find_option()
999 !strcmp(opts->long_name, longopt))) in find_option()
1000 return opts; in find_option()
1005 void set_option_flag(struct option *opts, int shortopt, const char *longopt, in set_option_flag() argument
1008 struct option *opt = find_option(opts, shortopt, longopt); in set_option_flag()
1015 void set_option_nobuild(struct option *opts, int shortopt, in set_option_nobuild() argument
1020 struct option *opt = find_option(opts, shortopt, longopt); in set_option_nobuild()