From cdb6cb55e05c05897ee3da91bb8979812fbb4602 Mon Sep 17 00:00:00 2001 From: pavelxdd Date: Mon, 11 Dec 2017 21:40:43 +0300 Subject: options: don't report errors on help value for OPT_COLOR The same idea as in 3723e61 but for OPT_COLOR now. Added missing closing bracket in the help message. --- options/m_option.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'options') diff --git a/options/m_option.c b/options/m_option.c index 8bcd5b4bab..e9ffe5d491 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1746,6 +1746,10 @@ static int parse_color(struct mp_log *log, const m_option_t *opt, if (param.len == 0) return M_OPT_MISSING_PARAM; + bool is_help = bstr_equals0(param, "help"); + if (is_help) + goto error; + bstr val = param; struct m_color color = {0}; @@ -1790,12 +1794,14 @@ static int parse_color(struct mp_log *log, const m_option_t *opt, return 1; error: - mp_err(log, "Option %.*s: invalid color: '%.*s'\n", - BSTR_P(name), BSTR_P(param)); - mp_err(log, "Valid colors must be in the form #RRGGBB or #AARRGGBB (in hex)\n" - "Or in the form 'r/g/b/a', where each component is a value in the\n" - "range 0.0-1.0. (Also allowed: 'gray', 'gray/a', 'r/g/b'.\n"); - return M_OPT_INVALID; + if (!is_help) { + mp_err(log, "Option %.*s: invalid color: '%.*s'\n", + BSTR_P(name), BSTR_P(param)); + } + mp_info(log, "Valid colors must be in the form #RRGGBB or #AARRGGBB (in hex)\n" + "or in the form 'r/g/b/a', where each component is a value in the\n" + "range 0.0-1.0. (Also allowed: 'gray', 'gray/a', 'r/g/b').\n"); + return is_help ? M_OPT_EXIT : M_OPT_INVALID; } const m_option_type_t m_option_type_color = { -- cgit v1.2.3