diff options
author | wm4 <wm4@nowhere> | 2013-07-21 20:16:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-21 23:27:31 +0200 |
commit | 560738ddef94ae3df325154e7932f5fb6e97915e (patch) | |
tree | bf85ab98dc360c569dbc08c5f1db506bc94f681d /core/m_config.c | |
parent | 6629a95b928499a46c9686f0800b65aec7fcbb22 (diff) | |
download | mpv-560738ddef94ae3df325154e7932f5fb6e97915e.tar.bz2 mpv-560738ddef94ae3df325154e7932f5fb6e97915e.tar.xz |
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.
Diffstat (limited to 'core/m_config.c')
-rw-r--r-- | core/m_config.c | 44 |
1 files changed, 26 insertions, 18 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); |