diff options
-rw-r--r-- | m_option.c | 18 | ||||
-rw-r--r-- | m_option.h | 2 | ||||
-rw-r--r-- | parser-mpcmd.c | 11 |
3 files changed, 29 insertions, 2 deletions
diff --git a/m_option.c b/m_option.c index 64a06d8971..34b7cd7a99 100644 --- a/m_option.c +++ b/m_option.c @@ -36,6 +36,24 @@ #include "stream/url.h" #include "libavutil/avstring.h" +char *m_option_strerror(int code) +{ + switch (code) { + case M_OPT_UNKNOWN: + return mp_gtext("Unrecognized option name"); + case M_OPT_MISSING_PARAM: + return mp_gtext("Required parameter for option missing"); + case M_OPT_INVALID: + return mp_gtext("Option parameter could not be parsed"); + case M_OPT_OUT_OF_RANGE: + return mp_gtext("Parameter is outside values allowed for option"); + case M_OPT_PARSER_ERR: + return mp_gtext("Parser error"); + default: + return NULL; + } +} + static const struct m_option *m_option_list_findb(const struct m_option *list, struct bstr name) { diff --git a/m_option.h b/m_option.h index 48f94781a3..78ed856f6d 100644 --- a/m_option.h +++ b/m_option.h @@ -423,6 +423,8 @@ struct m_option { #define ERR_OUT_OF_RANGE M_OPT_OUT_OF_RANGE #define ERR_FUNC_ERR M_OPT_PARSER_ERR +char *m_option_strerror(int code); + // Find the option matching the given name in the list. /** \ingroup Options * This function takes the possible wildcards into account (see diff --git a/parser-mpcmd.c b/parser-mpcmd.c index 112c5fdba8..59b35f0faa 100644 --- a/parser-mpcmd.c +++ b/parser-mpcmd.c @@ -192,8 +192,15 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, if (r <= M_OPT_EXIT) { opt_exit = true; r = M_OPT_EXIT - r; - } else if (r < 0) - goto print_err; + } else if (r < 0) { + char *msg = m_option_strerror(r); + if (!msg) + goto print_err; + mp_tmsg(MSGT_CFGPARSER, MSGL_FATAL, + "Error parsing commandline option \"%.*s\": %s\n", + BSTR_P(orig_opt), msg); + goto err_out; + } if (old_syntax) i += r; } |