diff mbox series

[v2,3/5] qdev-monitor: Make device options help nicer

Message ID 20181019164929.18404-4-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series Various option help readability improvement suggestions | expand

Commit Message

Max Reitz Oct. 19, 2018, 4:49 p.m. UTC
Just like in qemu_opts_print_help(), print the device name as a caption
instead of on every single line, indent all options, add angle brackets
around types, and align the descriptions after 24 characters.  Also,
separate the descriptions with " - " instead of putting them in
parentheses, because that is what we do everywhere else.  This does look
a bit funny here because basically all bits have the description
"on/off", but funny does not mean it is less readable.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 qdev-monitor.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Nov. 5, 2018, 8:14 a.m. UTC | #1
On Fri, Oct 19, 2018 at 8:49 PM Max Reitz <mreitz@redhat.com> wrote:
>
> Just like in qemu_opts_print_help(), print the device name as a caption
> instead of on every single line, indent all options, add angle brackets
> around types, and align the descriptions after 24 characters.  Also,
> separate the descriptions with " - " instead of putting them in
> parentheses, because that is what we do everywhere else.  This does look
> a bit funny here because basically all bits have the description
> "on/off", but funny does not mean it is less readable.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  qdev-monitor.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 802c18a74e..07147c63bf 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -285,10 +285,19 @@ int qdev_device_help(QemuOpts *opts)
>          goto error;
>      }
>
> +    if (prop_list) {
> +        out_printf("%s options:\n", driver);
> +    } else {
> +        out_printf("There are no options for %s.\n", driver);
> +    }
>      for (prop = prop_list; prop; prop = prop->next) {
> -        out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type);
> +        int len;
> +        out_printf("  %s=<%s>%n", prop->value->name, prop->value->type, &len);
>          if (prop->value->has_description) {
> -            out_printf(" (%s)\n", prop->value->description);
> +            if (len < 24) {
> +                out_printf("%*s", 24 - len, "");
> +            }
> +            out_printf(" - %s\n", prop->value->description);
>          } else {
>              out_printf("\n");
>          }
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/qdev-monitor.c b/qdev-monitor.c
index 802c18a74e..07147c63bf 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -285,10 +285,19 @@  int qdev_device_help(QemuOpts *opts)
         goto error;
     }
 
+    if (prop_list) {
+        out_printf("%s options:\n", driver);
+    } else {
+        out_printf("There are no options for %s.\n", driver);
+    }
     for (prop = prop_list; prop; prop = prop->next) {
-        out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type);
+        int len;
+        out_printf("  %s=<%s>%n", prop->value->name, prop->value->type, &len);
         if (prop->value->has_description) {
-            out_printf(" (%s)\n", prop->value->description);
+            if (len < 24) {
+                out_printf("%*s", 24 - len, "");
+            }
+            out_printf(" - %s\n", prop->value->description);
         } else {
             out_printf("\n");
         }