All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH 09/27] qemu-img: commit: refresh options/--help
Date: Tue, 13 May 2025 18:24:50 +0200	[thread overview]
Message-ID: <aCNyUhzVfX6sQF0P@redhat.com> (raw)
In-Reply-To: <20240927061121.573271-10-mjt@tls.msk.ru>

Am 27.09.2024 um 08:11 hat Michael Tokarev geschrieben:
> Add missing long options and --help output.
> 
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  qemu-img.c | 44 ++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 36 insertions(+), 8 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 9157a6b45d..7a111bce72 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1048,24 +1048,50 @@ static int img_commit(const img_cmd_t *ccmd, int argc, char **argv)
>      for(;;) {
>          static const struct option long_options[] = {
>              {"help", no_argument, 0, 'h'},
> +            {"quiet", no_argument, 0, 'q'},
>              {"object", required_argument, 0, OPTION_OBJECT},
> +            {"format", required_argument, 0, 'f'},
>              {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
> +            {"cache", required_argument, 0, 't'},
> +            {"drop", no_argument, 0, 'd'},
> +            {"base", required_argument, 0, 'b'},
> +            {"progress", no_argument, 0, 'p'},
> +            {"rate", required_argument, 0, 'r'},

"rate-limit"?

>              {0, 0, 0, 0}
>          };
> -        c = getopt_long(argc, argv, ":f:ht:b:dpqr:",
> +        c = getopt_long(argc, argv, "f:ht:b:dpqr:",
>                          long_options, NULL);

Should we try to keep the order in long_options and in the getopt string
consistent? There doesn't seem to be any system behind the order we have
currently. Maybe keep common options (--help, --quiet) first, but then
order things alphabetically?

It doesn't really matter that much here, it would just improve
legibility of the code a bit. But I think in the help text, we should
definitely have a more obvious order so that users can find their option
without having to read everything.

Of course, this is a comment that applies not only to this patch, but to
all subcommands.

>          if (c == -1) {
>              break;
>          }
>          switch(c) {
> -        case ':':
> -            missing_argument(argv[optind - 1]);
> -            break;
> -        case '?':
> -            unrecognized_option(argv[optind - 1]);
> -            break;
>          case 'h':
> -            help();
> +            cmd_help(ccmd,
> +"[-f FMT | --image-opts] [-t CACHE_MODE] [-b BASE_IMG] [-d]\n"
> +"        [-r RATE] [--object OBJDEF] FILENAME\n"
> +,
> +"  -q, --quiet\n"
> +"     quiet operations\n"

Same as in the previous patch. After this one, I won't point out things
any more if I already commented on the same thing earlier in the series.
They should apply to all similar instances.

> +"  -p, --progress\n"
> +"     show operation progress\n"

The man page has "display progress bar" (even though it's not a bar).
Maybe make it "display progress information" in both places?

> +"  -f, --format FMT\n"
> +"     specify FILENAME image format explicitly\n"
> +"  --image-opts\n"
> +"     indicates that FILENAME is a complete image specification\n"
> +"     instead of a file name (incompatible with --format)\n"
> +"  -t, --cache CACHE_MODE image cache mode (" BDRV_DEFAULT_CACHE ")\n"
> +"  -d, --drop\n"
> +"     skip emptying FILENAME on completion\n"
> +"  -b, --base BASE_IMG\n"
> +"     image in the backing chain to which to commit changes\n"
> +"     instead of the previous one (implies --drop)\n"

"image in the backing chain to commit change to (default: immediate
backing file; implies --drop)"?

> +"  -r, --rate RATE\n"
> +"     I/O rate limit\n"

in bytes per second

> +"  --object OBJDEF\n"
> +"     QEMU user-creatable object (eg encryption key)\n"
> +"  FILENAME\n"
> +"     name of the image file to operate on\n"
> +);
>              break;
>          case 'f':
>              fmt = optarg;
> @@ -1099,6 +1125,8 @@ static int img_commit(const img_cmd_t *ccmd, int argc, char **argv)
>          case OPTION_IMAGE_OPTS:
>              image_opts = true;
>              break;
> +        default:
> +            tryhelp(argv[0]);
>          }
>      }

Kevin



  reply	other threads:[~2025-05-13 16:25 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27  6:10 [PATCH resend v3 00/27] qemu-img: refersh options and --help handling, cleanups Michael Tokarev
2024-09-27  6:10 ` [PATCH 01/27] qemu-img: measure: convert img_size to signed, simplify handling Michael Tokarev
2024-11-05 19:27   ` Kevin Wolf
2024-09-27  6:10 ` [PATCH 02/27] qemu-img: create: " Michael Tokarev
2024-11-05 19:27   ` Kevin Wolf
2024-09-27  6:10 ` [PATCH 03/27] qemu-img: global option processing and error printing Michael Tokarev
2024-11-05 19:29   ` Kevin Wolf
2024-09-27  6:10 ` [PATCH 04/27] qemu-img: pass current cmd info into command handlers Michael Tokarev
2024-11-05 19:29   ` Kevin Wolf
2024-09-27  6:10 ` [PATCH 05/27] qemu-img: create: refresh options/--help Michael Tokarev
2024-11-05 19:57   ` Kevin Wolf
2024-09-27  6:11 ` [PATCH 06/27] qemu-img: factor out parse_output_format() and use it in the code Michael Tokarev
2025-05-13 15:25   ` Kevin Wolf
2024-09-27  6:11 ` [PATCH 07/27] qemu-img: check: refresh options/--help Michael Tokarev
2025-05-13 15:54   ` Kevin Wolf
2025-05-15  6:50     ` Michael Tokarev
2025-05-15  7:53       ` Kevin Wolf
2025-05-31 16:51     ` Michael Tokarev
2025-06-02 10:44       ` Kevin Wolf
2024-09-27  6:11 ` [PATCH 08/27] qemu-img: simplify --repair error message Michael Tokarev
2025-05-13 16:05   ` Kevin Wolf
2024-09-27  6:11 ` [PATCH 09/27] qemu-img: commit: refresh options/--help Michael Tokarev
2025-05-13 16:24   ` Kevin Wolf [this message]
2024-09-27  6:11 ` [PATCH 10/27] qemu-img: compare: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 11/27] qemu-img: convert: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 12/27] qemu-img: info: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 13/27] qemu-img: map: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 14/27] qemu-img: snapshot: allow specifying -f fmt Michael Tokarev
2024-09-27  6:11 ` [PATCH 15/27] qemu-img: snapshot: make -l (list) the default, simplify option handling Michael Tokarev
2024-09-27  6:11 ` [PATCH 16/27] qemu-img: snapshot: refresh options/--help Michael Tokarev
2024-09-27  6:11 ` [PATCH 17/27] qemu-img: rebase: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 18/27] qemu-img: resize: do not always eat last argument Michael Tokarev
2024-09-27  6:11 ` [PATCH 19/27] qemu-img: resize: refresh options/--help Michael Tokarev
2024-09-27  6:11 ` [PATCH 20/27] qemu-img: amend: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 21/27] qemu-img: bench: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 22/27] qemu-img: bitmap: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 23/27] qemu-img: dd: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 24/27] qemu-img: measure: " Michael Tokarev
2024-09-27  6:11 ` [PATCH 25/27] qemu-img: implement short --help, remove global help() function Michael Tokarev
2024-09-27  6:11 ` [PATCH 26/27] qemu-img: inline list of supported commands, remove qemu-img-cmds.h include Michael Tokarev
2024-09-27  6:11 ` [PATCH 27/27] qemu-img: extend cvtnum() and use it in more places Michael Tokarev
2024-10-23  6:15 ` [PATCH resend v3 00/27] qemu-img: refersh options and --help handling, cleanups Michael Tokarev
  -- strict thread matches above, loose matches on Subject: below --
2025-05-31 17:15 [PATCH v4 00/27] refresh qemu-img options handling Michael Tokarev
2025-05-31 17:15 ` [PATCH 09/27] qemu-img: commit: refresh options/--help Michael Tokarev
2024-04-24  8:50 [PATCH v3 00/27] qemu-img: refersh options and --help handling, cleanups Michael Tokarev
2024-04-24  8:50 ` [PATCH 09/27] qemu-img: commit: refresh options/--help Michael Tokarev

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=aCNyUhzVfX6sQF0P@redhat.com \
    --to=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.