summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-22 22:52:31 +0100
committerwm4 <wm4@nowhere>2019-11-23 01:18:49 +0100
commit251069d9ea481c14e418a63bfb2a471314fd4764 (patch)
tree4b8a10f5b89a1ade86092fbdfd34dae79f4f5eaa
parent6e0e39b79f1a024fb8dd98101c5fc63a8ec0d8ed (diff)
downloadmpv-251069d9ea481c14e418a63bfb2a471314fd4764.tar.bz2
mpv-251069d9ea481c14e418a63bfb2a471314fd4764.tar.xz
command: add command-list property
-rw-r--r--DOCS/man/input.rst8
-rw-r--r--player/command.c25
2 files changed, 33 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 02264f0eda..0ef5f9bb72 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2633,6 +2633,14 @@ Property list
is not a map, as order matters and duplicate entries are possible. Recursive
profiles are not expanded, and show up as special ``profile`` options.
+``command-list``
+ Return the list of input commands. This returns an array of maps, where
+ each map node represents a command. This map currently only has a single
+ entry: ``name`` for the name of the command. (This property is supposed to
+ be a replacement for ``--input-cmdlist``. The option dumps some more
+ information, but it's a valid feature request to extend this property if
+ needed.)
+
Inconsistencies between options and properties
----------------------------------------------
diff --git a/player/command.c b/player/command.c
index 85a44e3603..d667eb844f 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3481,6 +3481,30 @@ static int mp_profile_list(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_commands(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ switch (action) {
+ case M_PROPERTY_GET_TYPE:
+ *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
+ return M_PROPERTY_OK;
+ case M_PROPERTY_GET: {
+ struct mpv_node *root = arg;
+ node_init(root, MPV_FORMAT_NODE_ARRAY, NULL);
+
+ for (int n = 0; mp_cmds[n].name; n++) {
+ const struct mp_cmd_def *cmd = &mp_cmds[n];
+ struct mpv_node *entry = node_array_add(root, MPV_FORMAT_NODE_MAP);
+
+ node_map_add_string(entry, "name", cmd->name);
+ }
+
+ return M_PROPERTY_OK;
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
// Redirect a property name to another
#define M_PROPERTY_ALIAS(name, real_property) \
{(name), mp_property_alias, .priv = (real_property)}
@@ -3666,6 +3690,7 @@ static const struct m_property mp_properties_base[] = {
{"option-info", mp_property_option_info},
{"property-list", mp_property_list},
{"profile-list", mp_profile_list},
+ {"command-list", mp_property_commands},
{"play-dir", mp_property_play_direction},