summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/input.rst26
1 files changed, 21 insertions, 5 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 16daa1fb82..6df7890383 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -210,11 +210,10 @@ This applies to certain APIs, such as ``mp.command_native()`` (with tables that
have string keys) in Lua scripting, or ``mpv_command_node()`` (with
MPV_FORMAT_NODE_MAP) in the C libmpv client API.
-Like with array commands, quoting and escaping is inherently not needed in the
-normal case.
-
-The name of each command is defined in each command description in the
-`List of Input Commands`_. ``--input-cmdlist`` also lists them.
+The name of the command is provided with a ``name`` string field. The name of
+each command is defined in each command description in the
+`List of Input Commands`_. ``--input-cmdlist`` also lists them. See the
+``subprocess`` command for an example.
Some commands do not support named arguments (e.g. ``run`` command). You need
to use APIs that pass arguments as arrays.
@@ -597,6 +596,23 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
run while the player is in idle mode, or if you don't want that end of
playback kills the command.
+ .. admonition:: Example
+
+ ::
+
+ local r = mp.command_native({
+ name = "subprocess",
+ playback_only = false,
+ capture_stdout = true,
+ args = {"cat", "/proc/cpuinfo"},
+ })
+ if r.status == 0 then
+ print("result: " .. r.stdout)
+ end
+
+ This is a fairly useless Lua example, which demonstrates how to run
+ a process in a blocking manner, and retrieving its stdout output.
+
``quit [<code>]``
Exit the player. If an argument is given, it's used as process exit code.