Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/parse-options.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / parse-options.h` 646 lines ยท 19753 bytes Raw Blame History 1 #ifndef PARSE_OPTIONS_H 2 #define PARSE_OPTIONS_H 3 4 #include "gettext.h" 5 6 struct repository; 7 8 /** 9 * Refer to Documentation/technical/api-parse-options.adoc for the API doc. 10 */ 11 12 enum parse_opt_type { 13 /* special types */ 14 OPTION_END, 15 OPTION_GROUP, 16 OPTION_NUMBER, 17 OPTION_ALIAS, 18 OPTION_SUBCOMMAND, 19 /* options with no arguments */ 20 OPTION_BIT, 21 OPTION_NEGBIT, 22 OPTION_BITOP, 23 OPTION_COUNTUP, 24 OPTION_SET_INT, 25 /* options with arguments (usually) */ 26 OPTION_STRING, 27 OPTION_INTEGER, 28 OPTION_UNSIGNED, 29 OPTION_CALLBACK, 30 OPTION_LOWLEVEL_CALLBACK, 31 OPTION_FILENAME 32 }; 33 34 enum parse_opt_flags { 35 PARSE_OPT_KEEP_DASHDASH = 1 << 0, 36 PARSE_OPT_STOP_AT_NON_OPTION = 1 << 1, 37 PARSE_OPT_KEEP_ARGV0 = 1 << 2, 38 PARSE_OPT_KEEP_UNKNOWN_OPT = 1 << 3, 39 PARSE_OPT_NO_INTERNAL_HELP = 1 << 4, 40 PARSE_OPT_ONE_SHOT = 1 << 5, 41 PARSE_OPT_SHELL_EVAL = 1 << 6, 42 PARSE_OPT_SUBCOMMAND_OPTIONAL = 1 << 7, 43 }; 44 45 enum parse_opt_option_flags { 46 PARSE_OPT_OPTARG = 1 << 0, 47 PARSE_OPT_NOARG = 1 << 1, 48 PARSE_OPT_NONEG = 1 << 2, 49 PARSE_OPT_HIDDEN = 1 << 3, 50 PARSE_OPT_LASTARG_DEFAULT = 1 << 4, 51 PARSE_OPT_NODASH = 1 << 5, 52 PARSE_OPT_LITERAL_ARGHELP = 1 << 6, 53 PARSE_OPT_FROM_ALIAS = 1 << 7, 54 PARSE_OPT_NOCOMPLETE = 1 << 9, 55 PARSE_OPT_COMP_ARG = 1 << 10, 56 PARSE_OPT_CMDMODE = 1 << 11, 57 }; 58 59 enum parse_opt_result { 60 PARSE_OPT_COMPLETE = -4, 61 PARSE_OPT_HELP_ERROR = -3, 62 PARSE_OPT_HELP = -2, 63 PARSE_OPT_ERROR = -1, /* must be the same as error() */ 64 PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ 65 PARSE_OPT_NON_OPTION, 66 PARSE_OPT_SUBCOMMAND, 67 PARSE_OPT_UNKNOWN 68 }; 69 70 struct option; 71 typedef int parse_opt_cb(const struct option *, const char *arg, int unset); 72 73 struct parse_opt_ctx_t; 74 typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx, 75 const struct option *opt, 76 const char *arg, int unset); 77 78 typedef int parse_opt_subcommand_fn(int argc, const char **argv, 79 const char *prefix, struct repository *repo); 80 81 /* 82 * `type`:: 83 * holds the type of the option, you must have an OPTION_END last in your 84 * array. 85 * 86 * `short_name`:: 87 * the character to use as a short option name, '\0' if none. 88 * 89 * `long_name`:: 90 * the long option (without the leading dashes) or subcommand name, 91 * NULL if none. 92 * 93 * `value`:: 94 * stores pointers to the values to be filled. 95 * 96 * `precision`:: 97 * precision of the integer pointed to by `value` in number of bytes. Should 98 * typically be its `sizeof()`. 99 * 100 * `argh`:: 101 * token to explain the kind of argument this option wants. Does not 102 * begin in capital letter, and does not end with a full stop. 103 * Should be wrapped by N_() for translation. 104 * Is automatically enclosed in brackets when printed, unless it 105 * contains any of the following characters: ()<>[]| 106 * E.g. "name" is shown as "" to indicate that a name value 107 * needs to be supplied, not the literal string "name", but 108 * "," and "(this|that)" are printed verbatim. 109 * 110 * `help`:: 111 * the short help associated to what the option does. 112 * Must never be NULL (except for OPTION_END and OPTION_SUBCOMMAND). 113 * OPTION_GROUP uses this pointer to store the group header. 114 * Should be wrapped by N_() for translation. 115 * 116 * `flags`:: 117 * mask of parse_opt_option_flags. 118 * PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs) 119 * PARSE_OPT_NOARG: says that this option does not take an argument 120 * PARSE_OPT_NONEG: says that this option cannot be negated 121 * (i.e. rejects "--no-