Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 1 | #ifndef PARSE_OPTIONS_H |
| 2 | #define PARSE_OPTIONS_H |
| 3 | |
| 4 | enum parse_opt_type { |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 5 | /* special types */ |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 6 | OPTION_END, |
Pierre Habouzit | 580d5bf | 2008-03-02 11:35:56 +0100 | [diff] [blame] | 7 | OPTION_ARGUMENT, |
Pierre Habouzit | d7a38c5 | 2007-10-15 01:38:30 +0200 | [diff] [blame] | 8 | OPTION_GROUP, |
René Scharfe | e0319ff | 2009-05-07 21:45:08 +0200 | [diff] [blame] | 9 | OPTION_NUMBER, |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 10 | /* options with no arguments */ |
| 11 | OPTION_BIT, |
René Scharfe | 2f4b97f | 2009-05-07 21:44:17 +0200 | [diff] [blame] | 12 | OPTION_NEGBIT, |
Junio C Hamano | b04ba2b | 2011-09-27 16:56:49 -0700 | [diff] [blame] | 13 | OPTION_COUNTUP, |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 14 | OPTION_SET_INT, |
| 15 | OPTION_SET_PTR, |
| 16 | /* options with arguments (usually) */ |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 17 | OPTION_STRING, |
| 18 | OPTION_INTEGER, |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 19 | OPTION_CALLBACK, |
Jonathan Nieder | b0b3a8b | 2010-12-01 17:32:16 -0600 | [diff] [blame] | 20 | OPTION_LOWLEVEL_CALLBACK, |
Stephen Boyd | df217ed | 2009-05-23 11:53:13 -0700 | [diff] [blame] | 21 | OPTION_FILENAME |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 22 | }; |
| 23 | |
Junio C Hamano | b04ba2b | 2011-09-27 16:56:49 -0700 | [diff] [blame] | 24 | /* Deprecated synonym */ |
| 25 | #define OPTION_BOOLEAN OPTION_COUNTUP |
| 26 | |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 27 | enum parse_opt_flags { |
| 28 | PARSE_OPT_KEEP_DASHDASH = 1, |
Johannes Schindelin | a0ec9d2 | 2008-02-29 01:45:09 +0000 | [diff] [blame] | 29 | PARSE_OPT_STOP_AT_NON_OPTION = 2, |
Pierre Habouzit | a32a4ea | 2008-06-24 00:31:31 +0200 | [diff] [blame] | 30 | PARSE_OPT_KEEP_ARGV0 = 4, |
René Scharfe | b5ce3a5 | 2009-03-08 19:12:47 +0100 | [diff] [blame] | 31 | PARSE_OPT_KEEP_UNKNOWN = 8, |
Gary V. Vaughan | 4b05548 | 2010-05-14 09:31:35 +0000 | [diff] [blame] | 32 | PARSE_OPT_NO_INTERNAL_HELP = 16 |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 33 | }; |
| 34 | |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 35 | enum parse_opt_option_flags { |
| 36 | PARSE_OPT_OPTARG = 1, |
Pierre Habouzit | f481e22 | 2007-10-16 00:32:38 +0200 | [diff] [blame] | 37 | PARSE_OPT_NOARG = 2, |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 38 | PARSE_OPT_NONEG = 4, |
Pierre Habouzit | dd3bf0f | 2007-11-19 10:21:44 +0100 | [diff] [blame] | 39 | PARSE_OPT_HIDDEN = 8, |
Pierre Habouzit | 1cc6985 | 2008-07-08 12:34:08 +0200 | [diff] [blame] | 40 | PARSE_OPT_LASTARG_DEFAULT = 16, |
René Scharfe | 51a9949 | 2009-05-07 21:45:42 +0200 | [diff] [blame] | 41 | PARSE_OPT_NODASH = 32, |
Stephen Boyd | 29f25d4 | 2009-05-21 00:33:17 -0700 | [diff] [blame] | 42 | PARSE_OPT_LITERAL_ARGHELP = 64, |
Thomas Rast | 47e9cd2 | 2010-06-12 14:57:39 +0200 | [diff] [blame] | 43 | PARSE_OPT_SHELL_EVAL = 256 |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct option; |
| 47 | typedef int parse_opt_cb(const struct option *, const char *arg, int unset); |
| 48 | |
Jonathan Nieder | b0b3a8b | 2010-12-01 17:32:16 -0600 | [diff] [blame] | 49 | struct parse_opt_ctx_t; |
| 50 | typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx, |
| 51 | const struct option *opt, int unset); |
| 52 | |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 53 | /* |
| 54 | * `type`:: |
| 55 | * holds the type of the option, you must have an OPTION_END last in your |
| 56 | * array. |
| 57 | * |
| 58 | * `short_name`:: |
| 59 | * the character to use as a short option name, '\0' if none. |
| 60 | * |
| 61 | * `long_name`:: |
| 62 | * the long option name, without the leading dashes, NULL if none. |
| 63 | * |
| 64 | * `value`:: |
| 65 | * stores pointers to the values to be filled. |
| 66 | * |
| 67 | * `argh`:: |
| 68 | * token to explain the kind of argument this option wants. Keep it |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 69 | * homogeneous across the repository. Should be wrapped by N_() for |
| 70 | * translation. |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 71 | * |
| 72 | * `help`:: |
| 73 | * the short help associated to what the option does. |
| 74 | * Must never be NULL (except for OPTION_END). |
| 75 | * OPTION_GROUP uses this pointer to store the group header. |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 76 | * Should be wrapped by N_() for translation. |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 77 | * |
| 78 | * `flags`:: |
| 79 | * mask of parse_opt_option_flags. |
Mike Ralphson | 3ea3c21 | 2009-04-17 19:13:30 +0100 | [diff] [blame] | 80 | * PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs) |
Jonathan Nieder | ef45e4d | 2010-08-22 21:56:38 +0530 | [diff] [blame] | 81 | * PARSE_OPT_NOARG: says that this option does not take an argument |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 82 | * PARSE_OPT_NONEG: says that this option cannot be negated |
René Scharfe | 51a9949 | 2009-05-07 21:45:42 +0200 | [diff] [blame] | 83 | * PARSE_OPT_HIDDEN: this option is skipped in the default usage, and |
| 84 | * shown only in the full usage. |
Stephen Boyd | e169b97 | 2009-06-07 16:39:15 -0700 | [diff] [blame] | 85 | * PARSE_OPT_LASTARG_DEFAULT: says that this option will take the default |
| 86 | * value if no argument is given when the option |
| 87 | * is last on the command line. If the option is |
| 88 | * not last it will require an argument. |
| 89 | * Should not be used with PARSE_OPT_OPTARG. |
René Scharfe | 51a9949 | 2009-05-07 21:45:42 +0200 | [diff] [blame] | 90 | * PARSE_OPT_NODASH: this option doesn't start with a dash. |
Stephen Boyd | 29f25d4 | 2009-05-21 00:33:17 -0700 | [diff] [blame] | 91 | * PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets |
| 92 | * (i.e. '<argh>') in the help message. |
| 93 | * Useful for options with multiple parameters. |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 94 | * |
| 95 | * `callback`:: |
Jonathan Nieder | b0b3a8b | 2010-12-01 17:32:16 -0600 | [diff] [blame] | 96 | * pointer to the callback to use for OPTION_CALLBACK or |
| 97 | * OPTION_LOWLEVEL_CALLBACK. |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 98 | * |
| 99 | * `defval`:: |
| 100 | * default value to fill (*->value) with for PARSE_OPT_OPTARG. |
Pierre Habouzit | db7244b | 2007-11-07 11:20:27 +0100 | [diff] [blame] | 101 | * OPTION_{BIT,SET_INT,SET_PTR} store the {mask,integer,pointer} to put in |
| 102 | * the value when met. |
Pierre Habouzit | 9b3beb5 | 2007-11-05 13:03:22 +0100 | [diff] [blame] | 103 | * CALLBACKS can use it like they want. |
| 104 | */ |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 105 | struct option { |
| 106 | enum parse_opt_type type; |
| 107 | int short_name; |
| 108 | const char *long_name; |
| 109 | void *value; |
Pierre Habouzit | d7a38c5 | 2007-10-15 01:38:30 +0200 | [diff] [blame] | 110 | const char *argh; |
| 111 | const char *help; |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 112 | |
| 113 | int flags; |
| 114 | parse_opt_cb *callback; |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 115 | intptr_t defval; |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | #define OPT_END() { OPTION_END } |
Stephen Boyd | 34aec9f | 2009-06-04 16:43:57 -0700 | [diff] [blame] | 119 | #define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \ |
| 120 | (h), PARSE_OPT_NOARG} |
Pierre Habouzit | d7a38c5 | 2007-10-15 01:38:30 +0200 | [diff] [blame] | 121 | #define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) } |
Stephen Boyd | 34aec9f | 2009-06-04 16:43:57 -0700 | [diff] [blame] | 122 | #define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), \ |
| 123 | PARSE_OPT_NOARG, NULL, (b) } |
| 124 | #define OPT_NEGBIT(s, l, v, h, b) { OPTION_NEGBIT, (s), (l), (v), NULL, \ |
| 125 | (h), PARSE_OPT_NOARG, NULL, (b) } |
Junio C Hamano | b04ba2b | 2011-09-27 16:56:49 -0700 | [diff] [blame] | 126 | #define OPT_COUNTUP(s, l, v, h) { OPTION_COUNTUP, (s), (l), (v), NULL, \ |
Stephen Boyd | 34aec9f | 2009-06-04 16:43:57 -0700 | [diff] [blame] | 127 | (h), PARSE_OPT_NOARG } |
| 128 | #define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \ |
| 129 | (h), PARSE_OPT_NOARG, NULL, (i) } |
Junio C Hamano | b04ba2b | 2011-09-27 16:56:49 -0700 | [diff] [blame] | 130 | #define OPT_BOOL(s, l, v, h) OPT_SET_INT(s, l, v, h, 1) |
Stephen Boyd | 34aec9f | 2009-06-04 16:43:57 -0700 | [diff] [blame] | 131 | #define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \ |
| 132 | (h), PARSE_OPT_NOARG, NULL, (p) } |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 133 | #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) } |
Pierre Habouzit | d7a38c5 | 2007-10-15 01:38:30 +0200 | [diff] [blame] | 134 | #define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } |
Jeff King | c8ba163 | 2011-06-09 11:55:23 -0400 | [diff] [blame] | 135 | #define OPT_STRING_LIST(s, l, v, a, h) \ |
| 136 | { OPTION_CALLBACK, (s), (l), (v), (a), \ |
| 137 | (h), 0, &parse_opt_string_list } |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 138 | #define OPT_UYN(s, l, v, h) { OPTION_CALLBACK, (s), (l), (v), NULL, \ |
| 139 | (h), PARSE_OPT_NOARG, &parse_opt_tertiary } |
Michele Ballabio | 1f4a711 | 2008-03-24 15:02:21 +0100 | [diff] [blame] | 140 | #define OPT_DATE(s, l, v, h) \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 141 | { OPTION_CALLBACK, (s), (l), (v), N_("time"),(h), 0, \ |
Michele Ballabio | 1f4a711 | 2008-03-24 15:02:21 +0100 | [diff] [blame] | 142 | parse_opt_approxidate_cb } |
Junio C Hamano | 27ec394 | 2013-04-25 11:13:49 -0700 | [diff] [blame] | 143 | #define OPT_EXPIRY_DATE(s, l, v, h) \ |
| 144 | { OPTION_CALLBACK, (s), (l), (v), N_("expiry date"),(h), 0, \ |
| 145 | parse_opt_expiry_date_cb } |
Pierre Habouzit | ffe659f | 2007-10-15 01:45:45 +0200 | [diff] [blame] | 146 | #define OPT_CALLBACK(s, l, v, a, h, f) \ |
| 147 | { OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) } |
René Scharfe | e0319ff | 2009-05-07 21:45:08 +0200 | [diff] [blame] | 148 | #define OPT_NUMBER_CALLBACK(v, h, f) \ |
| 149 | { OPTION_NUMBER, 0, NULL, (v), NULL, (h), \ |
| 150 | PARSE_OPT_NOARG | PARSE_OPT_NONEG, (f) } |
Stephen Boyd | df217ed | 2009-05-23 11:53:13 -0700 | [diff] [blame] | 151 | #define OPT_FILENAME(s, l, v, h) { OPTION_FILENAME, (s), (l), (v), \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 152 | N_("file"), (h) } |
Mark Lodato | 73e9da0 | 2010-02-16 23:55:58 -0500 | [diff] [blame] | 153 | #define OPT_COLOR_FLAG(s, l, v, h) \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 154 | { OPTION_CALLBACK, (s), (l), (v), N_("when"), (h), PARSE_OPT_OPTARG, \ |
Mark Lodato | 73e9da0 | 2010-02-16 23:55:58 -0500 | [diff] [blame] | 155 | parse_opt_color_flag_cb, (intptr_t)"always" } |
| 156 | |
René Scharfe | 6acec03 | 2011-09-28 19:44:30 +0200 | [diff] [blame] | 157 | #define OPT_NOOP_NOARG(s, l) \ |
| 158 | { OPTION_CALLBACK, (s), (l), NULL, NULL, \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 159 | N_("no-op (backward compatibility)"), \ |
René Scharfe | 6acec03 | 2011-09-28 19:44:30 +0200 | [diff] [blame] | 160 | PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb } |
| 161 | |
Junio C Hamano | b04ba2b | 2011-09-27 16:56:49 -0700 | [diff] [blame] | 162 | /* Deprecated synonym */ |
| 163 | #define OPT_BOOLEAN OPT_COUNTUP |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 164 | |
| 165 | /* parse_options() will filter out the processed options and leave the |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 166 | * non-option arguments in argv[]. usagestr strings should be marked |
| 167 | * for translation with N_(). |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 168 | * Returns the number of arguments left in argv[]. |
| 169 | */ |
Stephen Boyd | 3778292 | 2009-05-23 11:53:12 -0700 | [diff] [blame] | 170 | extern int parse_options(int argc, const char **argv, const char *prefix, |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 171 | const struct option *options, |
Pierre Habouzit | d7a38c5 | 2007-10-15 01:38:30 +0200 | [diff] [blame] | 172 | const char * const usagestr[], int flags); |
| 173 | |
| 174 | extern NORETURN void usage_with_options(const char * const *usagestr, |
| 175 | const struct option *options); |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 176 | |
Christian Couder | 451bb21 | 2009-02-02 06:12:58 +0100 | [diff] [blame] | 177 | extern NORETURN void usage_msg_opt(const char *msg, |
| 178 | const char * const *usagestr, |
| 179 | const struct option *options); |
| 180 | |
Dmitry Ivankov | 1f275b7 | 2011-08-11 15:15:37 +0600 | [diff] [blame] | 181 | extern int optbug(const struct option *opt, const char *reason); |
| 182 | extern int opterror(const struct option *opt, const char *reason, int flags); |
Eric Sunshine | a3bc3d0 | 2013-08-09 05:06:17 -0400 | [diff] [blame] | 183 | #if defined(__GNUC__) && ! defined(__clang__) |
Jeff King | a469a10 | 2012-12-15 12:42:10 -0500 | [diff] [blame] | 184 | #define opterror(o,r,f) (opterror((o),(r),(f)), -1) |
| 185 | #endif |
| 186 | |
Mike Ralphson | 3ea3c21 | 2009-04-17 19:13:30 +0100 | [diff] [blame] | 187 | /*----- incremental advanced APIs -----*/ |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 188 | |
Pierre Habouzit | ee68b87 | 2008-06-23 22:28:04 +0200 | [diff] [blame] | 189 | enum { |
| 190 | PARSE_OPT_HELP = -1, |
| 191 | PARSE_OPT_DONE, |
Jonathan Nieder | 979240f | 2010-12-01 17:32:55 -0600 | [diff] [blame] | 192 | PARSE_OPT_NON_OPTION, |
Gary V. Vaughan | 4b05548 | 2010-05-14 09:31:35 +0000 | [diff] [blame] | 193 | PARSE_OPT_UNKNOWN |
Pierre Habouzit | ee68b87 | 2008-06-23 22:28:04 +0200 | [diff] [blame] | 194 | }; |
| 195 | |
Pierre Habouzit | 26141b5 | 2008-06-23 22:55:11 +0200 | [diff] [blame] | 196 | /* |
| 197 | * It's okay for the caller to consume argv/argc in the usual way. |
| 198 | * Other fields of that structure are private to parse-options and should not |
| 199 | * be modified in any way. |
| 200 | */ |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 201 | struct parse_opt_ctx_t { |
| 202 | const char **argv; |
| 203 | const char **out; |
| 204 | int argc, cpidx; |
| 205 | const char *opt; |
| 206 | int flags; |
Stephen Boyd | 3778292 | 2009-05-23 11:53:12 -0700 | [diff] [blame] | 207 | const char *prefix; |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | extern void parse_options_start(struct parse_opt_ctx_t *ctx, |
Stephen Boyd | 3778292 | 2009-05-23 11:53:12 -0700 | [diff] [blame] | 211 | int argc, const char **argv, const char *prefix, |
Stephen Boyd | 9ca1169 | 2010-12-05 23:57:42 -0800 | [diff] [blame] | 212 | const struct option *options, int flags); |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 213 | |
Pierre Habouzit | ff43ec3 | 2008-06-23 22:38:58 +0200 | [diff] [blame] | 214 | extern int parse_options_step(struct parse_opt_ctx_t *ctx, |
| 215 | const struct option *options, |
| 216 | const char * const usagestr[]); |
| 217 | |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 218 | extern int parse_options_end(struct parse_opt_ctx_t *ctx); |
| 219 | |
Junio C Hamano | 8b74d75 | 2010-03-06 21:34:40 +0100 | [diff] [blame] | 220 | extern int parse_options_concat(struct option *dst, size_t, struct option *src); |
Pierre Habouzit | 7e7bbcb | 2008-06-23 21:59:37 +0200 | [diff] [blame] | 221 | |
Pierre Habouzit | 0ce865b | 2007-10-14 11:05:12 +0200 | [diff] [blame] | 222 | /*----- some often used options -----*/ |
| 223 | extern int parse_opt_abbrev_cb(const struct option *, const char *, int); |
Michele Ballabio | 1f4a711 | 2008-03-24 15:02:21 +0100 | [diff] [blame] | 224 | extern int parse_opt_approxidate_cb(const struct option *, const char *, int); |
Junio C Hamano | 27ec394 | 2013-04-25 11:13:49 -0700 | [diff] [blame] | 225 | extern int parse_opt_expiry_date_cb(const struct option *, const char *, int); |
Mark Lodato | 73e9da0 | 2010-02-16 23:55:58 -0500 | [diff] [blame] | 226 | extern int parse_opt_color_flag_cb(const struct option *, const char *, int); |
Tuncer Ayaz | 7f87aff | 2008-11-15 01:14:24 +0100 | [diff] [blame] | 227 | extern int parse_opt_verbosity_cb(const struct option *, const char *, int); |
Jake Goulding | 269defd | 2009-01-26 09:13:23 -0500 | [diff] [blame] | 228 | extern int parse_opt_with_commit(const struct option *, const char *, int); |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 229 | extern int parse_opt_tertiary(const struct option *, const char *, int); |
Jeff King | c8ba163 | 2011-06-09 11:55:23 -0400 | [diff] [blame] | 230 | extern int parse_opt_string_list(const struct option *, const char *, int); |
René Scharfe | 6acec03 | 2011-09-28 19:44:30 +0200 | [diff] [blame] | 231 | extern int parse_opt_noop_cb(const struct option *, const char *, int); |
Pierre Habouzit | 0ce865b | 2007-10-14 11:05:12 +0200 | [diff] [blame] | 232 | |
René Scharfe | fd03881 | 2010-11-08 18:56:39 +0100 | [diff] [blame] | 233 | #define OPT__VERBOSE(var, h) OPT_BOOLEAN('v', "verbose", (var), (h)) |
René Scharfe | d52ee6e | 2010-11-08 19:06:54 +0100 | [diff] [blame] | 234 | #define OPT__QUIET(var, h) OPT_BOOLEAN('q', "quiet", (var), (h)) |
Tuncer Ayaz | 7f87aff | 2008-11-15 01:14:24 +0100 | [diff] [blame] | 235 | #define OPT__VERBOSITY(var) \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 236 | { OPTION_CALLBACK, 'v', "verbose", (var), NULL, N_("be more verbose"), \ |
Tuncer Ayaz | 7f87aff | 2008-11-15 01:14:24 +0100 | [diff] [blame] | 237 | PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }, \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 238 | { OPTION_CALLBACK, 'q', "quiet", (var), NULL, N_("be more quiet"), \ |
Tuncer Ayaz | 7f87aff | 2008-11-15 01:14:24 +0100 | [diff] [blame] | 239 | PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 } |
René Scharfe | e21adb8 | 2010-11-08 18:58:51 +0100 | [diff] [blame] | 240 | #define OPT__DRY_RUN(var, h) OPT_BOOLEAN('n', "dry-run", (var), (h)) |
René Scharfe | 76946b7 | 2010-11-08 19:01:54 +0100 | [diff] [blame] | 241 | #define OPT__FORCE(var, h) OPT_BOOLEAN('f', "force", (var), (h)) |
Pierre Habouzit | 0ce865b | 2007-10-14 11:05:12 +0200 | [diff] [blame] | 242 | #define OPT__ABBREV(var) \ |
Nguyễn Thái Ngọc Duy | 54e6dc7 | 2012-05-06 21:23:51 +0700 | [diff] [blame] | 243 | { OPTION_CALLBACK, 0, "abbrev", (var), N_("n"), \ |
| 244 | N_("use <n> digits to display SHA-1s"), \ |
Pierre Habouzit | 0ce865b | 2007-10-14 11:05:12 +0200 | [diff] [blame] | 245 | PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 } |
Mark Lodato | 73e9da0 | 2010-02-16 23:55:58 -0500 | [diff] [blame] | 246 | #define OPT__COLOR(var, h) \ |
| 247 | OPT_COLOR_FLAG(0, "color", (var), (h)) |
Nguyễn Thái Ngọc Duy | 7e29b82 | 2012-04-21 11:44:32 +0700 | [diff] [blame] | 248 | #define OPT_COLUMN(s, l, v, h) \ |
Nguyễn Thái Ngọc Duy | a054e04 | 2012-08-20 19:31:50 +0700 | [diff] [blame] | 249 | { OPTION_CALLBACK, (s), (l), (v), N_("style"), (h), PARSE_OPT_OPTARG, parseopt_column_callback } |
Pierre Habouzit | 0ce865b | 2007-10-14 11:05:12 +0200 | [diff] [blame] | 250 | |
Pierre Habouzit | 4a59fd1 | 2007-10-15 01:35:37 +0200 | [diff] [blame] | 251 | #endif |