提交 ce564eb1 编写于 作者: M Michael Haggerty 提交者: Junio C Hamano

parse-options: add parse_opt_unknown_cb()

Add a new callback function, parse_opt_unknown_cb(), which returns -2 to
indicate that the corresponding option is unknown. This can be used to
add "-h" documentation for an option that will be handled externally to
parse_options().
Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 433860f3
......@@ -153,6 +153,18 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
return 0;
}
/**
* Report that the option is unknown, so that other code can handle
* it. This can be used as a callback together with
* OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the
* "-h" output even if it's not being handled directly by
* parse_options().
*/
int parse_opt_unknown_cb(const struct option *opt, const char *arg, int unset)
{
return -2;
}
/**
* Recreates the command-line option in the strbuf.
*/
......
......@@ -228,6 +228,7 @@ extern int parse_opt_commits(const struct option *, const char *, int);
extern int parse_opt_tertiary(const struct option *, const char *, int);
extern int parse_opt_string_list(const struct option *, const char *, int);
extern int parse_opt_noop_cb(const struct option *, const char *, int);
extern int parse_opt_unknown_cb(const struct option *, const char *, int);
extern int parse_opt_passthru(const struct option *, const char *, int);
extern int parse_opt_passthru_argv(const struct option *, const char *, int);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册