summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-31 17:32:57 +0100
committerwm4 <wm4@nowhere>2019-10-31 17:32:57 +0100
commit706e708d2f17c68ceb13443fffd25053020da126 (patch)
tree86b2bc20869c596fb5ef55f52325d1afa014bddc
parente96ab5becb3afda9683bb4779937b94d27ac8fda (diff)
downloadmpv-706e708d2f17c68ceb13443fffd25053020da126.tar.bz2
mpv-706e708d2f17c68ceb13443fffd25053020da126.tar.xz
options: make --show-profile without parameters list all profiles
-rw-r--r--DOCS/man/options.rst3
-rw-r--r--options/m_config.c19
-rw-r--r--options/options.c4
3 files changed, 17 insertions, 9 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 0ebc7d5058..e18e6492b0 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -761,7 +761,8 @@ Program Behavior
(Default: disabled)
``--show-profile=<profile>``
- Show the description and content of a profile.
+ Show the description and content of a profile. Lists all profiles if no
+ parameter is provided.
``--use-filedir-conf``
Look for a file-specific configuration file in the same directory as the
diff --git a/options/m_config.c b/options/m_config.c
index 7085d3d6fa..4be8594fac 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -129,11 +129,21 @@ static struct m_group_data *m_config_gdata(struct m_config_data *data,
return &data->gdata[group_index - data->group_index];
}
+static void list_profiles(struct m_config *config)
+{
+ MP_INFO(config, "Available profiles:\n");
+ for (struct m_profile *p = config->profiles; p; p = p->next)
+ MP_INFO(config, "\t%s\t%s\n", p->name, p->desc ? p->desc : "");
+ MP_INFO(config, "\n");
+}
+
static int show_profile(struct m_config *config, bstr param)
{
struct m_profile *p;
- if (!param.len)
- return M_OPT_MISSING_PARAM;
+ if (!param.len) {
+ list_profiles(config);
+ return M_OPT_EXIT;
+ }
if (!(p = m_config_get_profile(config, param))) {
MP_ERR(config, "Unknown profile '%.*s'.\n", BSTR_P(param));
return M_OPT_EXIT;
@@ -758,10 +768,7 @@ static int m_config_handle_special_options(struct m_config *config,
MP_INFO(config, "No profiles have been defined.\n");
return M_OPT_EXIT;
}
- MP_INFO(config, "Available profiles:\n");
- for (struct m_profile *p = config->profiles; p; p = p->next)
- MP_INFO(config, "\t%s\t%s\n", p->name, p->desc ? p->desc : "");
- MP_INFO(config, "\n");
+ list_profiles(config);
return M_OPT_EXIT;
}
diff --git a/options/options.c b/options/options.c
index 9bac67101c..4fbf9d6401 100644
--- a/options/options.c
+++ b/options/options.c
@@ -332,8 +332,8 @@ const m_option_t mp_opts[] = {
// handled in m_config.c
{ "include", CONF_TYPE_STRING, M_OPT_FILE, .offset = -1},
{ "profile", CONF_TYPE_STRING_LIST, 0, .offset = -1},
- { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP,
- .offset = -1},
+ { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED |
+ M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, .offset = -1},
{ "list-options", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_FIXED |
M_OPT_NOPROP, .offset = -1},
OPT_FLAG("list-properties", property_print_help,