diff options
author | wm4 <wm4@nowhere> | 2016-08-31 17:09:10 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-08-31 22:16:19 +0200 |
commit | 7dde096d8a6d9e82cac82bec439fef47d078f352 (patch) | |
tree | 4b6656fb69f4ec62b114ebd3cab0c5e8470a9fbb /options/m_config.c | |
parent | e024906408c4d079e77b136de9b0562a93daadce (diff) | |
download | mpv-7dde096d8a6d9e82cac82bec439fef47d078f352.tar.bz2 mpv-7dde096d8a6d9e82cac82bec439fef47d078f352.tar.xz |
m_config: introduce and use OPT_ALIAS for some options
OPT_ALIAS redirects the options at a higher level, instead of
introducing "duplicate" options with different name but same backing
storage. This uses the OPT_REPLACED mechanisms - only the deprecation
warning had to be made conditional. Note that e.g. --no-video still
works, because the "--no-..." redirection and OPT_ALIAS are orthogonal.
The deprecated --sub -> --sub-file alias had to be dropped, because it
essentially conflicts with --no-sub. If anyone complains, this could
probably still be undone by letting m_config_find_negation_opt do a
special mapping for --no-sub. (Which would be dumb, but simple and
effective.)
Diffstat (limited to 'options/m_config.c')
-rw-r--r-- | options/m_config.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/options/m_config.c b/options/m_config.c index cd18e57b9d..470951d233 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -362,6 +362,9 @@ static void m_config_add_option(struct m_config *config, co.name = talloc_asprintf(config, "%s-%s", parent_name, co.name); } + if (co.opt->deprecation_message) + co.is_hidden = true; + // Option with children -> add them if (arg->type->flags & M_OPT_TYPE_HAS_CHILD) { const struct m_sub_options *subopts = arg->priv; @@ -395,7 +398,6 @@ static void m_config_add_option(struct m_config *config, MP_TARRAY_APPEND(config, config->opts, config->num_opts, co); if (co.opt->type == &m_option_type_alias) { - co.is_hidden = true; const char *alias = (const char *)co.opt->priv; char no_alias[40]; snprintf(no_alias, sizeof(no_alias), "no-%s", alias); @@ -408,9 +410,6 @@ static void m_config_add_option(struct m_config *config, m_config_add_option(config, NULL, NULL, NULL, new); } } - - if (co.opt->type == &m_option_type_removed) - co.is_hidden = true; } struct m_config_option *m_config_get_co(const struct m_config *config, @@ -434,7 +433,9 @@ struct m_config_option *m_config_get_co(const struct m_config *config, const char *prefix = config->is_toplevel ? "--" : ""; if (co->opt->type == &m_option_type_alias) { const char *alias = (const char *)co->opt->priv; - if (!co->warning_was_printed) { + // deprecation_message is not used, but decides whether it's a + // proper or deprecated alias. + if (co->opt->deprecation_message && !co->warning_was_printed) { MP_WARN(config, "Warning: option %s%s was replaced with " "%s%s and might be removed in the future.\n", prefix, co->name, prefix, alias); @@ -788,9 +789,6 @@ void m_config_print_option_list(const struct m_config *config) continue; if (co->is_hidden) continue; - if (opt->type == &m_option_type_alias || - opt->type == &m_option_type_removed) - continue; MP_INFO(config, " %s%-30s", prefix, co->name); if (opt->type == &m_option_type_choice) { MP_INFO(config, " Choices:"); |