diff mbox series

[v2] monitor: print message when using 'help' with an unknown command

Message ID 1532115624-27568-1-git-send-email-walling@linux.ibm.com
State New
Headers show
Series [v2] monitor: print message when using 'help' with an unknown command | expand

Commit Message

Collin Walling July 20, 2018, 7:40 p.m. UTC
When typing 'help' followed by an unknown command, QEMU will
not print anything to the command line to let the user know
they typed a bad command. Let's fix this by printing a message
to the monitor when this happens. For example:

    (qemu) help xyz
    unknown command: 'xyz'

Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
Signed-off-by: Collin Walling <walling@linux.ibm.com>
---
 monitor.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Dr. David Alan Gilbert Aug. 8, 2018, 7 p.m. UTC | #1
* Collin Walling (walling@linux.ibm.com) wrote:
> When typing 'help' followed by an unknown command, QEMU will
> not print anything to the command line to let the user know
> they typed a bad command. Let's fix this by printing a message
> to the monitor when this happens. For example:
> 
>     (qemu) help xyz
>     unknown command: 'xyz'
> 
> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
> Signed-off-by: Collin Walling <walling@linux.ibm.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  monitor.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 7af1f18..deeb41c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1013,6 +1013,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>                            char **args, int nb_args, int arg_index)
>  {
>      const mon_cmd_t *cmd;
> +    size_t i;
>  
>      /* No valid arg need to compare with, dump all in *cmds */
>      if (arg_index >= nb_args) {
> @@ -1034,9 +1035,15 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>              } else {
>                  help_cmd_dump_one(mon, cmd, args, arg_index);
>              }
> -            break;
> +            return;
>          }
>      }
> +
> +    /* Command not found */
> +    monitor_printf(mon, "unknown command: '");
> +    for (i = 0; i <= arg_index; i++) {
> +        monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
> +    }
>  }
>  
>  static void help_cmd(Monitor *mon, const char *name)
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Collin Walling Sept. 6, 2018, 6:09 p.m. UTC | #2
On 08/08/2018 03:00 PM, Dr. David Alan Gilbert wrote:
> * Collin Walling (walling@linux.ibm.com) wrote:
>> When typing 'help' followed by an unknown command, QEMU will
>> not print anything to the command line to let the user know
>> they typed a bad command. Let's fix this by printing a message
>> to the monitor when this happens. For example:
>>
>>     (qemu) help xyz
>>     unknown command: 'xyz'
>>
>> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
>> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 

Thank you for the R-b. 

And pardon my impatience, but any chance this patch might get picked up, or
does it require some more review first?

[...]
Dr. David Alan Gilbert Sept. 6, 2018, 7:28 p.m. UTC | #3
* Collin Walling (walling@linux.ibm.com) wrote:
> On 08/08/2018 03:00 PM, Dr. David Alan Gilbert wrote:
> > * Collin Walling (walling@linux.ibm.com) wrote:
> >> When typing 'help' followed by an unknown command, QEMU will
> >> not print anything to the command line to let the user know
> >> they typed a bad command. Let's fix this by printing a message
> >> to the monitor when this happens. For example:
> >>
> >>     (qemu) help xyz
> >>     unknown command: 'xyz'
> >>
> >> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
> >> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> > 
> > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > 
> 
> Thank you for the R-b. 
> 
> And pardon my impatience, but any chance this patch might get picked up, or
> does it require some more review first?

It will on my next HMP pull; it's just not many pulls are happening
at the moment; it should be in by the end of the month.

Dave

> [...]
> 
> 
> -- 
> Respectfully,
> - Collin Walling
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Collin Walling Sept. 6, 2018, 8:35 p.m. UTC | #4
On 09/06/2018 03:28 PM, Dr. David Alan Gilbert wrote:
> * Collin Walling (walling@linux.ibm.com) wrote:
>> On 08/08/2018 03:00 PM, Dr. David Alan Gilbert wrote:
>>> * Collin Walling (walling@linux.ibm.com) wrote:
>>>> When typing 'help' followed by an unknown command, QEMU will
>>>> not print anything to the command line to let the user know
>>>> they typed a bad command. Let's fix this by printing a message
>>>> to the monitor when this happens. For example:
>>>>
>>>>     (qemu) help xyz
>>>>     unknown command: 'xyz'
>>>>
>>>> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
>>>> Signed-off-by: Collin Walling <walling@linux.ibm.com>
>>>
>>> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>>>
>>
>> Thank you for the R-b. 
>>
>> And pardon my impatience, but any chance this patch might get picked up, or
>> does it require some more review first?
> 
> It will on my next HMP pull; it's just not many pulls are happening
> at the moment; it should be in by the end of the month.
> 
> Dave

Fair enough. Thank you for the update.

> 
>> [...]
>>
>>
>> -- 
>> Respectfully,
>> - Collin Walling
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
Dr. David Alan Gilbert Sept. 25, 2018, 10:40 a.m. UTC | #5
* Collin Walling (walling@linux.ibm.com) wrote:
> When typing 'help' followed by an unknown command, QEMU will
> not print anything to the command line to let the user know
> they typed a bad command. Let's fix this by printing a message
> to the monitor when this happens. For example:
> 
>     (qemu) help xyz
>     unknown command: 'xyz'
> 
> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
> Signed-off-by: Collin Walling <walling@linux.ibm.com>

Queued (at last!)

> ---
>  monitor.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 7af1f18..deeb41c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1013,6 +1013,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>                            char **args, int nb_args, int arg_index)
>  {
>      const mon_cmd_t *cmd;
> +    size_t i;
>  
>      /* No valid arg need to compare with, dump all in *cmds */
>      if (arg_index >= nb_args) {
> @@ -1034,9 +1035,15 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>              } else {
>                  help_cmd_dump_one(mon, cmd, args, arg_index);
>              }
> -            break;
> +            return;
>          }
>      }
> +
> +    /* Command not found */
> +    monitor_printf(mon, "unknown command: '");
> +    for (i = 0; i <= arg_index; i++) {
> +        monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
> +    }
>  }
>  
>  static void help_cmd(Monitor *mon, const char *name)
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Collin Walling Sept. 25, 2018, 2:29 p.m. UTC | #6
On 09/25/2018 06:40 AM, Dr. David Alan Gilbert wrote:
> * Collin Walling (walling@linux.ibm.com) wrote:
>> When typing 'help' followed by an unknown command, QEMU will
>> not print anything to the command line to let the user know
>> they typed a bad command. Let's fix this by printing a message
>> to the monitor when this happens. For example:
>>
>>     (qemu) help xyz
>>     unknown command: 'xyz'
>>
>> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
>> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> 
> Queued (at last!)
> 

Great! Thanks David :)

>> ---
>>  monitor.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/monitor.c b/monitor.c
>> index 7af1f18..deeb41c 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -1013,6 +1013,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>>                            char **args, int nb_args, int arg_index)
>>  {
>>      const mon_cmd_t *cmd;
>> +    size_t i;
>>  
>>      /* No valid arg need to compare with, dump all in *cmds */
>>      if (arg_index >= nb_args) {
>> @@ -1034,9 +1035,15 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>>              } else {
>>                  help_cmd_dump_one(mon, cmd, args, arg_index);
>>              }
>> -            break;
>> +            return;
>>          }
>>      }
>> +
>> +    /* Command not found */
>> +    monitor_printf(mon, "unknown command: '");
>> +    for (i = 0; i <= arg_index; i++) {
>> +        monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
>> +    }
>>  }
>>  
>>  static void help_cmd(Monitor *mon, const char *name)
>> -- 
>> 2.7.4
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
diff mbox series

Patch

diff --git a/monitor.c b/monitor.c
index 7af1f18..deeb41c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1013,6 +1013,7 @@  static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
                           char **args, int nb_args, int arg_index)
 {
     const mon_cmd_t *cmd;
+    size_t i;
 
     /* No valid arg need to compare with, dump all in *cmds */
     if (arg_index >= nb_args) {
@@ -1034,9 +1035,15 @@  static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Command not found */
+    monitor_printf(mon, "unknown command: '");
+    for (i = 0; i <= arg_index; i++) {
+        monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
+    }
 }
 
 static void help_cmd(Monitor *mon, const char *name)