From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH 23/23] qemu-img: inline list of supported commands, remove qemu-img-cmds.h include
Date: Tue, 20 Feb 2024 18:48:35 +0000 [thread overview]
Message-ID: <ZdT0A3b9-JrMd6aI@redhat.com> (raw)
In-Reply-To: <a7e67594e748d1b91f755dd971f222afa09f5443.1707513012.git.mjt@tls.msk.ru>
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 <mjt@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 :|
next prev parent reply other threads:[~2024-02-20 18:49 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 21:22 [PATCH 00/23] qemu-img: refersh options and --help handling Michael Tokarev
2024-02-09 21:22 ` [PATCH 01/23] qemu-img: pass current cmd info into command handlers Michael Tokarev
2024-02-20 17:29 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 02/23] qemu-img: refresh options/--help for "create" subcommand Michael Tokarev
2024-02-20 18:41 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 03/23] qemu-img: factor out parse_output_format() and use it in the code Michael Tokarev
2024-02-20 17:38 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 04/23] qemu-img: refresh options/--help for "check" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 05/23] qemu-img: simplify --repair error message Michael Tokarev
2024-02-20 17:40 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 06/23] qemu-img: refresh options/--help for "commit" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 07/23] qemu-img: refresh options/--help for "compare" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 08/23] qemu-img: refresh options/--help for "convert" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 09/23] qemu-img: refresh options/--help for "info" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 10/23] qemu-img: refresh options/--help for "map" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 11/23] qemu-img: allow specifying -f fmt for snapshot subcommand Michael Tokarev
2024-02-09 21:41 ` Michael Tokarev
2024-02-20 17:41 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 12/23] qemu-img: make -l (list) the default for "snapshot" subcommand Michael Tokarev
2024-02-20 17:45 ` Daniel P. Berrangé
2024-02-20 18:51 ` Michael Tokarev
2024-02-21 12:12 ` Michael Tokarev
2024-02-09 21:22 ` [PATCH 13/23] qemu-img: refresh options/--help for "snapshot" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 14/23] qemu-img: refresh options/--help for "rebase" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 15/23] qemu-img: resize: do not always eat last argument Michael Tokarev
2024-02-20 17:57 ` Daniel P. Berrangé
2024-02-21 12:19 ` Michael Tokarev
2024-02-09 21:22 ` [PATCH 16/23] qemu-img: refresh options/--help for "resize" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 17/23] qemu-img: refresh options/--help for "amend" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 18/23] qemu-img: refresh options/--help for "bench" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 19/23] qemu-img: refresh options/--help for "bitmap" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 20/23] qemu-img: refresh options/--help for "dd" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 21/23] qemu-img: refresh options/--help for "measure" command Michael Tokarev
2024-02-09 21:22 ` [PATCH 22/23] qemu-img: implement short --help, remove global help() function Michael Tokarev
2024-02-20 18:46 ` Daniel P. Berrangé
2024-02-09 21:22 ` [PATCH 23/23] qemu-img: inline list of supported commands, remove qemu-img-cmds.h include Michael Tokarev
2024-02-20 18:48 ` Daniel P. Berrangé [this message]
2024-02-20 19:02 ` Michael Tokarev
2024-02-20 19:06 ` Daniel P. Berrangé
2024-02-21 16:31 ` Michael Tokarev
2024-02-21 16:45 ` Daniel P. Berrangé
2024-02-09 22:26 ` [PATCH 00/23] qemu-img: refersh options and --help handling Michael Tokarev
2024-02-20 18:53 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZdT0A3b9-JrMd6aI@redhat.com \
--to=berrange@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).