Patchwork [V5,6/7] monitor: improve "help" in auto completion for sub command

login
register
mail settings
Submitter Wayne Xia
Date June 29, 2013, 3:53 a.m.
Message ID <1372477981-7512-7-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/255714/
State New
Headers show

Comments

Wayne Xia - June 29, 2013, 3:53 a.m.
Now special case "help *" in auto completion can work with sub commands,
such as "help info a*".

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 monitor.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
Luiz Capitulino - July 8, 2013, 4:09 p.m.
On Sat, 29 Jun 2013 11:53:00 +0800
Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:

> Now special case "help *" in auto completion can work with sub commands,
> such as "help info a*".

The auto-completion works, but the command is still refused:

(qemu) help info u
usb       usbhost   usernet   uuid
(qemu) help info uuid
help: extraneous characters at the end of line

This is not hugely important, but I think it would make more sense
to make the command work before having auto-completion support.

> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  monitor.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 2f5b91d..3ef18ee 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4283,10 +4283,8 @@ static void monitor_find_completion_by_table(Monitor *mon,
>                      cmd_completion(mon, str, QKeyCode_lookup[i]);
>                  }
>              } else if (!strcmp(cmd->name, "help|?")) {
> -                readline_set_completion_index(mon->rs, strlen(str));
> -                for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
> -                    cmd_completion(mon, str, cmd->name);
> -                }
> +                monitor_find_completion_by_table(mon, cmd_table,
> +                                                 args_cmdline[1]);
>              }
>              break;
>          default:
Wayne Xia - July 10, 2013, 6:46 a.m.
于 2013-7-9 0:09, Luiz Capitulino 写道:
> On Sat, 29 Jun 2013 11:53:00 +0800
> Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
>
>> Now special case "help *" in auto completion can work with sub commands,
>> such as "help info a*".
>
> The auto-completion works, but the command is still refused:
>
> (qemu) help info u
> usb       usbhost   usernet   uuid
> (qemu) help info uuid
> help: extraneous characters at the end of line
>
> This is not hugely important, but I think it would make more sense
> to make the command work before having auto-completion support.
>
   Patch 7 fix it, I will adjust the patch sequence.


>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   monitor.c |    6 ++----
>>   1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/monitor.c b/monitor.c
>> index 2f5b91d..3ef18ee 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -4283,10 +4283,8 @@ static void monitor_find_completion_by_table(Monitor *mon,
>>                       cmd_completion(mon, str, QKeyCode_lookup[i]);
>>                   }
>>               } else if (!strcmp(cmd->name, "help|?")) {
>> -                readline_set_completion_index(mon->rs, strlen(str));
>> -                for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
>> -                    cmd_completion(mon, str, cmd->name);
>> -                }
>> +                monitor_find_completion_by_table(mon, cmd_table,
>> +                                                 args_cmdline[1]);
>>               }
>>               break;
>>           default:
>

Patch

diff --git a/monitor.c b/monitor.c
index 2f5b91d..3ef18ee 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4283,10 +4283,8 @@  static void monitor_find_completion_by_table(Monitor *mon,
                     cmd_completion(mon, str, QKeyCode_lookup[i]);
                 }
             } else if (!strcmp(cmd->name, "help|?")) {
-                readline_set_completion_index(mon->rs, strlen(str));
-                for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
-                    cmd_completion(mon, str, cmd->name);
-                }
+                monitor_find_completion_by_table(mon, cmd_table,
+                                                 args_cmdline[1]);
             }
             break;
         default: