From 0a7a4779a3772b26c6675910146b0d5a825d8b08 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 17 May 2018 20:34:31 +0200 Subject: input: slightly improve --input-cmdlist output Output argument names, whether varargs are used, and indicate optional arguments correctly (instead of only half of them). --- DOCS/man/input.rst | 2 +- input/cmd.c | 11 ++++++----- 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"); } } -- cgit v1.2.3