0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

options: make --show-profile without parameters list all profiles

This commit is contained in:
wm4 2019-10-31 17:32:57 +01:00
parent e96ab5becb
commit 706e708d2f
3 changed files with 17 additions and 9 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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,