On Sat, Feb 10, 2024 at 12:22:44AM +0300, Michael Tokarev wrote: > also add short description to each command and use it in --help > > Signed-off-by: Michael Tokarev <m...@tls.msk.ru> > --- > qemu-img.c | 42 +++++++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) > > diff --git a/qemu-img.c b/qemu-img.c > index d9c5c6078b..e57076738e 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -61,6 +61,7 @@ > typedef struct img_cmd_t { > const char *name; > int (*handler)(const struct img_cmd_t *ccmd, int argc, char **argv); > + const char *description; > } img_cmd_t; > > enum { > @@ -130,11 +131,12 @@ static G_NORETURN > void cmd_help(const img_cmd_t *ccmd, > const char *syntax, const char *arguments) > { > - printf("qemu-img %s %s" > + printf("qemu-img %s: %s. Usage:\n" > + "qemu-img %s %s"
This ends up looking a bit muddled together. I don't think we need repeat 'qemu-img <cmd>' twice, and could add a little more whitespace eg instead of: $ ./build/qemu-img check --help qemu-img check: Check basic image integrity. Usage: qemu-img check [-f FMT | --image-opts] [-T CACHE_MODE] [-r] [-u] [--output human|json] [--object OBJDEF] FILENAME Arguments: ...snip... have it look like $ ./build/qemu-img check --help Check basic image integrity. Usage: qemu-img check [-f FMT | --image-opts] [-T CACHE_MODE] [-r] [-u] [--output human|json] [--object OBJDEF] FILENAME Arguments: ...snip... > "Arguments:\n" > " -h|--help - print this help and exit\n" > "%s", > - ccmd->name, syntax, arguments); > + ccmd->name, ccmd->description, ccmd->name, syntax, arguments); > exit(EXIT_SUCCESS); > } > > @@ -5746,10 +5748,36 @@ out: > } > > static const img_cmd_t img_cmds[] = { > -#define DEF(option, callback, arg_string) \ > - { option, callback }, > -#include "qemu-img-cmds.h" > -#undef DEF > + { "amend", img_amend, > + "Update format-specific options of the image" }, > + { "bench", img_bench, > + "Run simple image benchmark" }, > + { "bitmap", img_bitmap, > + "Perform modifications of the persistent bitmap in the image" }, > + { "check", img_check, > + "Check basic image integrity" }, > + { "commit", img_commit, > + "Commit image to its backing file" }, > + { "compare", img_compare, > + "Check if two images have the same contents" }, > + { "convert", img_convert, > + "Copy one image to another with optional format conversion" }, > + { "create", img_create, > + "Create and format new image file" }, > + { "dd", img_dd, > + "Copy input to output with optional format conversion" }, > + { "info", img_info, > + "Display information about image" }, > + { "map", img_map, > + "Dump image metadata" }, > + { "measure", img_measure, > + "Calculate file size requred for a new image" }, > + { "rebase", img_rebase, > + "Change backing file of the image" }, > + { "resize", img_resize, > + "Resize the image to the new size" }, > + { "snapshot", img_snapshot, > + "List or manipulate snapshots within image" }, > { NULL, NULL, }, > }; > > @@ -5813,7 +5841,7 @@ QEMU_IMG_VERSION > " [[enable=]<pattern>][,events=<file>][,file=<file>]\n" > "Recognized commands (run qemu-img command --help for command-specific > help):\n"); > for (cmd = img_cmds; cmd->name != NULL; cmd++) { > - printf(" %s\n", cmd->name); > + printf(" %s - %s\n", cmd->name, cmd->description); > } > c = printf("Supported image formats:"); > bdrv_iterate_format(format_print, &c, false); > -- > 2.39.2 > > With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|