From 3f127448e8f2e85a5063ff5b37487a896fa4f6c7 Mon Sep 17 00:00:00 2001 From: pavelxdd Date: Mon, 11 Dec 2017 21:40:01 +0300 Subject: [PATCH] options: don't report errors on help value for OPT_FLAG The same idea as in 3723e61 but for OPT_FLAG now. --- options/m_option.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/options/m_option.c b/options/m_option.c index 9577c48577..8bcd5b4bab 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -135,13 +135,18 @@ static int parse_flag(struct mp_log *log, const m_option_t *opt, VAL(dst) = 0; return 1; } - mp_fatal(log, "Invalid parameter for %.*s flag: %.*s\n", - BSTR_P(name), BSTR_P(param)); - mp_info(log, "Valid values are:\n"); + bool is_help = bstr_equals0(param, "help"); + if (is_help) { + mp_info(log, "Valid values for %.*s flag are:\n", BSTR_P(name)); + } else { + mp_fatal(log, "Invalid parameter for %.*s flag: %.*s\n", + BSTR_P(name), BSTR_P(param)); + mp_info(log, "Valid values are:\n"); + } mp_info(log, " yes\n"); mp_info(log, " no\n"); mp_info(log, " (passing nothing)\n"); - return M_OPT_INVALID; + return is_help ? M_OPT_EXIT : M_OPT_INVALID; } static char *print_flag(const m_option_t *opt, const void *val)