Commit da3273ad authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf
Browse files

object: Make option help nicer to read



Just like in qemu_opts_print_help(), print the object 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, indent every object name in the list of available objects.

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 9c2762b4
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -2765,14 +2765,21 @@ static bool object_create_initial(const char *type, QemuOpts *opts)
            }

            str = g_string_new(NULL);
            g_string_append_printf(str, "%s.%s=%s", type,
                                   prop->name, prop->type);
            g_string_append_printf(str, "  %s=<%s>", prop->name, prop->type);
            if (prop->description) {
                if (str->len < 24) {
                    g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
                }
                g_string_append_printf(str, " - %s", prop->description);
            }
            g_ptr_array_add(array, g_string_free(str, false));
        }
        g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
        if (array->len > 0) {
            printf("%s options:\n", type);
        } else {
            printf("There are no options for %s.\n", type);
        }
        for (i = 0; i < array->len; i++) {
            printf("%s\n", (char *)array->pdata[i]);
        }