[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/27] qemu-img: map: refresh options/--help
From: |
Michael Tokarev |
Subject: |
[PATCH 13/27] qemu-img: map: refresh options/--help |
Date: |
Wed, 24 Apr 2024 11:50:21 +0300 |
Add missing long options and --help output.
While at it, remove unused option_index variable.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
qemu-img.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 34c4cd86de..84e2e53fb7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3454,7 +3454,6 @@ static int img_map(const img_cmd_t *ccmd, int argc, char
**argv)
fmt = NULL;
for (;;) {
- int option_index = 0;
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'},
@@ -3466,20 +3465,33 @@ static int img_map(const img_cmd_t *ccmd, int argc,
char **argv)
{"max-length", required_argument, 0, 'l'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, ":f:s:l:hU",
- long_options, &option_index);
+ c = getopt_long(argc, argv, "f:s:l:hU",
+ long_options, NULL);
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] [--object OBJDEF] [--output human|json]\n"
+" [--start-offset OFFSET] [--max-length LENGTH] [-U] FILENAME\n"
+,
+" -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"
+" --start-offset OFFSET\n"
+" --max-length LENGTH\n"
+" --output human|json\n"
+" specify output format name (default human)\n"
+" -U, --force-share\n"
+" open image in shared mode for concurrent access\n"
+" --object OBJDEF\n"
+" QEMU user-creatable object (eg encryption key)\n"
+" FILENAME\n"
+" image file name (or specification with --image-opts)\n"
+);
break;
case 'f':
fmt = optarg;
@@ -3508,6 +3520,8 @@ static int img_map(const img_cmd_t *ccmd, int argc, char
**argv)
case OPTION_IMAGE_OPTS:
image_opts = true;
break;
+ default:
+ tryhelp(argv[0]);
}
}
if (optind != argc - 1) {
--
2.39.2
- [PATCH 02/27] qemu-img: create: convert img_size to signed, simplify handling, (continued)
- [PATCH 02/27] qemu-img: create: convert img_size to signed, simplify handling, Michael Tokarev, 2024/04/24
- [PATCH 03/27] qemu-img: global option processing and error printing, Michael Tokarev, 2024/04/24
- [PATCH 04/27] qemu-img: pass current cmd info into command handlers, Michael Tokarev, 2024/04/24
- [PATCH 05/27] qemu-img: create: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 06/27] qemu-img: factor out parse_output_format() and use it in the code, Michael Tokarev, 2024/04/24
- [PATCH 10/27] qemu-img: compare: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 11/27] qemu-img: convert: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 07/27] qemu-img: check: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 08/27] qemu-img: simplify --repair error message, Michael Tokarev, 2024/04/24
- [PATCH 09/27] qemu-img: commit: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 13/27] qemu-img: map: refresh options/--help,
Michael Tokarev <=
- [PATCH 14/27] qemu-img: snapshot: allow specifying -f fmt, Michael Tokarev, 2024/04/24
- [PATCH 12/27] qemu-img: info: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 15/27] qemu-img: snapshot: make -l (list) the default, simplify option handling, Michael Tokarev, 2024/04/24
- [PATCH 16/27] qemu-img: snapshot: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 17/27] qemu-img: rebase: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 18/27] qemu-img: resize: do not always eat last argument, Michael Tokarev, 2024/04/24
- [PATCH 20/27] qemu-img: amend: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 19/27] qemu-img: resize: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 22/27] qemu-img: bitmap: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 21/27] qemu-img: bench: refresh options/--help, Michael Tokarev, 2024/04/24