diff options
| author | Jan Sucan <jan@jansucan.com> | 2024-03-24 15:05:53 +0100 |
|---|---|---|
| committer | Ján Sučan <jan@jansucan.com> | 2024-03-24 15:14:13 +0100 |
| commit | e54d3a1e4e7491c41610a6bac3789a10e8cdf7c6 (patch) | |
| tree | 09c0e52981ca6626cc0059184f18ca2b79c2b737 /src | |
| parent | d4a2243237fb591cce2e18cb98934dea8465efb4 (diff) | |
Remove the -h option
This simplifies parsing of the options. Help message is printed on wrong
arguments. Keep only the help operation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/options.cpp b/src/options.cpp index 51a9260..ecb1026 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -43,7 +43,6 @@ #define OPTIONS_DEFAULT_BUFFER_SIZE (4 * 1024 * 1024) struct common_options { - bool help; uint32_t sector_size; uint32_t buffer_size; }; @@ -149,7 +148,6 @@ options_parse_operation(const char *const op_name, options_t *const opts) static void options_init_common(struct common_options *const opts) { - opts->help = false; opts->sector_size = OPTIONS_DEFAULT_SECTOR_SIZE; opts->buffer_size = OPTIONS_DEFAULT_BUFFER_SIZE; } @@ -162,16 +160,12 @@ options_parse_common(int *const argc, char ***const argv, char *arg_sector_size = NULL; char *arg_buffer_size = NULL; - while ((ch = getopt(*argc, *argv, ":b:hs:")) != -1) { + while ((ch = getopt(*argc, *argv, ":b:s:")) != -1) { switch (ch) { case 'b': arg_buffer_size = optarg; break; - case 'h': - opts->help = true; - break; - case 's': arg_sector_size = optarg; break; @@ -223,9 +217,7 @@ options_parse_backup(int *const argc, char ***const argv, options_t *const opts) return false; } - if (common_opts.help) { - opts->operation_id = OPERATION_ID_HELP; - } else if (*argc < 3) { + if (*argc < 3) { print_error("missing arguments"); return false; } else if (*argc > 3) { @@ -252,9 +244,7 @@ options_parse_restore(int *const argc, char ***const argv, return false; } - if (common_opts.help) { - opts->operation_id = OPERATION_ID_HELP; - } else if (*argc < 2) { + if (*argc < 2) { print_error("missing arguments"); return false; } else if (*argc > 2) { |
