[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 33/36] object: Make option help nicer to read
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 33/36] object: Make option help nicer to read |
Date: |
Mon, 5 Nov 2018 17:37:41 +0100 |
From: Max Reitz <address@hidden>
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: Max Reitz <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
vl.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/vl.c b/vl.c
index 1fcacc5caa..bed97b92ac 100644
--- a/vl.c
+++ b/vl.c
@@ -2743,7 +2743,7 @@ static bool object_create_initial(const char *type,
QemuOpts *opts)
list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
for (l = list; l != NULL; l = l->next) {
ObjectClass *oc = OBJECT_CLASS(l->data);
- printf("%s\n", object_class_get_name(oc));
+ printf(" %s\n", object_class_get_name(oc));
}
g_slist_free(list);
exit(0);
@@ -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]);
}
--
2.19.1
- [Qemu-block] [PULL 32/36] qdev-monitor: Make device options help nicer, (continued)
- [Qemu-block] [PULL 32/36] qdev-monitor: Make device options help nicer, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 35/36] vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 20/36] block: Add auto-read-only option, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 34/36] fw_cfg: Drop newline in @file description, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 29/36] qemu-iotests: Test auto-read-only with -drive and -blockdev, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 24/36] file-posix: Support auto-read-only option, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 21/36] rbd: Close image in qemu_rbd_open() error path, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 26/36] gluster: Support auto-read-only option, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 36/36] include: Add a comment to explain the origin of sizes' lookup table, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 33/36] object: Make option help nicer to read,
Kevin Wolf <=
- [Qemu-block] [PULL 25/36] curl: Support auto-read-only option, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 27/36] iscsi: Support auto-read-only option, Kevin Wolf, 2018/11/05
- [Qemu-block] [PULL 13/36] block/vdi: Don't take address of fields in packed structs, Kevin Wolf, 2018/11/05
- Re: [Qemu-block] [PULL 00/36] Block layer patches, Peter Maydell, 2018/11/05