diff options
author | wm4 <wm4@nowhere> | 2020-07-19 15:36:41 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-07-20 21:02:17 +0200 |
commit | 4476911d45652d99df1e1a66b5aea48d4ef9a070 (patch) | |
tree | 2191dd3bddd655c5b629f0f46184b0a5329da5ba /DOCS | |
parent | d5959df2be17f6ccc47abb6f5b440e3bbcef246a (diff) | |
download | mpv-4476911d45652d99df1e1a66b5aea48d4ef9a070.tar.bz2 mpv-4476911d45652d99df1e1a66b5aea48d4ef9a070.tar.xz |
manpage: add named arguments "subprocess" example
At the same time, this is an example for a command with named arguments.
Diffstat (limited to 'DOCS')
-rw-r--r-- | DOCS/man/input.rst | 26 |
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. |