[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/16] monitor: support sub command in auto completio
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 14/16] monitor: support sub command in auto completion |
Date: |
Fri, 30 Aug 2013 08:22:35 -0400 |
From: Wenchao Xia <address@hidden>
This patch allows auto completion work normal for sub command case,
"info block [DEVICE]" can auto complete now, by re-enter the completion
function. In original code "info" is treated as a special case, now it
is treated as a sub command group, global variable info_cmds is not used
any more.
"help" command is still treated as a special case, since it is not a sub
command group but want to auto complete command in root command table.
Signed-off-by: Wenchao Xia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/monitor.c b/monitor.c
index 424d30c..c44c711 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4262,6 +4262,12 @@ static void monitor_find_completion_by_table(Monitor
*mon,
return;
}
+ if (cmd->sub_table) {
+ /* do the job again */
+ return monitor_find_completion_by_table(mon, cmd->sub_table,
+ &args[1], nb_args - 1);
+ }
+
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
@@ -4288,13 +4294,7 @@ static void monitor_find_completion_by_table(Monitor
*mon,
bdrv_iterate(block_completion_it, &mbs);
break;
case 's':
- /* XXX: more generic ? */
- if (!strcmp(cmd->name, "info")) {
- readline_set_completion_index(mon->rs, strlen(str));
- for(cmd = info_cmds; cmd->name != NULL; cmd++) {
- cmd_completion(mon, str, cmd->name);
- }
- } else if (!strcmp(cmd->name, "sendkey")) {
+ if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
--
1.8.1.4
- [Qemu-devel] [PULL 03/16] monitor: avoid use of global *cur_mon in file_completion(), (continued)
- [Qemu-devel] [PULL 03/16] monitor: avoid use of global *cur_mon in file_completion(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 05/16] monitor: avoid use of global *cur_mon in monitor_find_completion(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 06/16] monitor: avoid use of global *cur_mon in readline_completion(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 07/16] monitor: call sortcmdlist() only one time, Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 08/16] monitor: split off monitor_data_init(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 09/16] monitor: avoid direct use of global variable *mon_cmds, Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 10/16] monitor: code move for parse_cmdline(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 11/16] monitor: refine parse_cmdline(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 12/16] monitor: support sub command in help, Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 13/16] monitor: refine monitor_find_completion(), Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 14/16] monitor: support sub command in auto completion,
Luiz Capitulino <=
- [Qemu-devel] [PULL 15/16] monitor: allow "help" show message for single command in sub group, Luiz Capitulino, 2013/08/30
- [Qemu-devel] [PULL 16/16] monitor: improve auto complete of "help" for single command in sub group, Luiz Capitulino, 2013/08/30