From 560738ddef94ae3df325154e7932f5fb6e97915e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 21 Jul 2013 20:16:46 +0200 Subject: m_config: improve option list output a bit This is printed with --list-options or e.g. --vf=lavfi=help. Note that in theory, the options should be able to print their own help, and we shouldn't special case certain types (like m_option_type_choice in the commit). But that is too hairy for now, so we don't do it. --- core/m_config.c | 44 ++++++++++++++++++++++++++------------------ core/m_option.c | 2 +- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/core/m_config.c b/core/m_config.c index a447621009..84713276df 100644 --- a/core/m_config.c +++ b/core/m_config.c @@ -655,28 +655,36 @@ void m_config_print_option_list(const struct m_config *config) if (!config->opts) return; - mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, - "\n Name Type Min Max Global Cfg\n\n"); + mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "Options:\n\n"); for (co = config->opts; co; co = co->next) { const struct m_option *opt = co->opt; if (opt->type->flags & M_OPT_TYPE_HAS_CHILD) continue; - if (opt->flags & M_OPT_MIN) - sprintf(min, "%-8.0f", opt->min); - else - strcpy(min, "No"); - if (opt->flags & M_OPT_MAX) - sprintf(max, "%-8.0f", opt->max); - else - strcpy(max, "No"); - mp_msg(MSGT_CFGPARSER, MSGL_INFO, - " %-20.20s %-15.15s %-10.10s %-10.10s %-3.3s %-3.3s\n", - co->name, - co->opt->type->name, - min, - max, - opt->flags & CONF_GLOBAL ? "Yes" : "No", - opt->flags & CONF_NOCFG ? "No" : "Yes"); + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-30.30s", co->name); + if (opt->type == &m_option_type_choice) { + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " Choices:"); + struct m_opt_choice_alternatives *alt = opt->priv; + for (int n = 0; alt[n].name; n++) + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", alt[n].name); + if (opt->flags & (M_OPT_MIN | M_OPT_MAX)) + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " (or an integer)"); + } else { + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", co->opt->type->name); + } + if (opt->flags & (M_OPT_MIN | M_OPT_MAX)) { + snprintf(min, sizeof(min), "any"); + snprintf(max, sizeof(max), "any"); + if (opt->flags & M_OPT_MIN) + snprintf(min, sizeof(min), "%g", opt->min); + if (opt->flags & M_OPT_MAX) + snprintf(max, sizeof(max), "%g", opt->max); + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " (%s to %s)", min, max); + } + if (opt->flags & CONF_GLOBAL) + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " [global]"); + if (opt->flags & CONF_NOCFG) + mp_msg(MSGT_CFGPARSER, MSGL_INFO, " [nocfg]"); + mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n"); count++; } mp_tmsg(MSGT_CFGPARSER, MSGL_INFO, "\nTotal: %d options\n", count); diff --git a/core/m_option.c b/core/m_option.c index b6f329c51f..ff27f9bcc7 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -2098,7 +2098,7 @@ static int parse_obj_settings(struct bstr opt, struct bstr *pstr, *pstr = bstr_cut(*pstr, next); if (!bstrcmp0(param, "help")) { mp_msg(MSGT_CFGPARSER, MSGL_INFO, - "Option %.*s: %.*s have no option description.\n", + "Option %.*s: %.*s has no option description.\n", BSTR_P(opt), BSTR_P(str)); return M_OPT_EXIT - 1; } -- cgit v1.2.3