]> git.ipfire.org Git - thirdparty/git.git/blame - parse-options.h
Rework make_usage to print the usage message immediately
[thirdparty/git.git] / parse-options.h
CommitLineData
4a59fd13
PH
1#ifndef PARSE_OPTIONS_H
2#define PARSE_OPTIONS_H
3
4enum parse_opt_type {
5 OPTION_END,
d7a38c54 6 OPTION_GROUP,
4a59fd13
PH
7 OPTION_BOOLEAN,
8 OPTION_STRING,
9 OPTION_INTEGER,
10};
11
12enum parse_opt_flags {
13 PARSE_OPT_KEEP_DASHDASH = 1,
14};
15
16struct option {
17 enum parse_opt_type type;
18 int short_name;
19 const char *long_name;
20 void *value;
d7a38c54
PH
21 const char *argh;
22 const char *help;
4a59fd13
PH
23};
24
25#define OPT_END() { OPTION_END }
d7a38c54
PH
26#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
27#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
28#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) }
29#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
4a59fd13
PH
30
31/* parse_options() will filter out the processed options and leave the
32 * non-option argments in argv[].
33 * Returns the number of arguments left in argv[].
34 */
35extern int parse_options(int argc, const char **argv,
36 const struct option *options,
d7a38c54
PH
37 const char * const usagestr[], int flags);
38
39extern NORETURN void usage_with_options(const char * const *usagestr,
40 const struct option *options);
4a59fd13
PH
41
42#endif