summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-17 20:34:31 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commit0a7a4779a3772b26c6675910146b0d5a825d8b08 (patch)
tree7a1f2bc8b9b78ff6b1691286a23a2a7c0ff7ef21
parent332907e1d7225ae39565d462aac5c45c3a5cad97 (diff)
downloadmpv-0a7a4779a3772b26c6675910146b0d5a825d8b08.tar.bz2
mpv-0a7a4779a3772b26c6675910146b0d5a825d8b08.tar.xz
input: slightly improve --input-cmdlist output
Output argument names, whether varargs are used, and indicate optional arguments correctly (instead of only half of them).
-rw-r--r--DOCS/man/input.rst2
-rw-r--r--input/cmd.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index d2c92d7476..b577b688d0 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -138,7 +138,7 @@ 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`_.
+`List of Input Commands`_. ``--input-cmdlist`` also lists them.
Some commands do not support named arguments (e.g. ``run`` command). You need
to use APIs that pass arguments as arrays.
diff --git a/input/cmd.c b/input/cmd.c
index 7e50f0784b..0a6bd73931 100644
--- a/input/cmd.c
+++ b/input/cmd.c
@@ -597,12 +597,13 @@ void mp_print_cmd_list(struct mp_log *out)
const struct mp_cmd_def *def = &mp_cmds[i];
mp_info(out, "%-20.20s", def->name);
for (int j = 0; j < MP_CMD_DEF_MAX_ARGS && def->args[j].type; j++) {
- const char *type = def->args[j].type->name;
- if (def->args[j].defval)
- mp_info(out, " [%s]", type);
- else
- mp_info(out, " %s", type);
+ const struct m_option *arg = &def->args[j];
+ bool is_opt = arg->defval || (arg->flags & MP_CMD_OPT_ARG);
+ mp_info(out, " %s%s=%s%s", is_opt ? "[" : "", arg->name,
+ arg->type->name, is_opt ? "]" : "");
}
+ if (def->vararg)
+ mp_info(out, "..."); // essentially append to last argument
mp_info(out, "\n");
}
}