From 948a65cf39c8ce31c5adc0f24979e0cb55bc33c3 Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Sat, 18 Jun 2022 08:50:45 +0200 Subject: Refactor the command line interface Select operation by its name instead of by number of the arguments. --- src/options.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/options.h') diff --git a/src/options.h b/src/options.h index 9ffa14f..e162fbe 100644 --- a/src/options.h +++ b/src/options.h @@ -27,20 +27,40 @@ #ifndef OPTIONS_H #define OPTIONS_H +#include "operation_id.h" + #include #include typedef struct { - bool help; uint32_t sector_size; uint32_t buffer_size; - const char *in_file_path; const char *ref_file_path; const char *out_file_path; +} options_backup_t; + +typedef struct { + uint32_t sector_size; + uint32_t buffer_size; + const char *in_file_path; + const char *out_file_path; +} options_restore_t; + +typedef struct { + operation_id_t operation_id; + + union { + options_backup_t backup; + options_restore_t restore; + } op; } options_t; -int options_parse(int argc, char **argv, options_t *const opts); +bool options_parse(int argc, char **argv, options_t *const opts); void options_usage(int exit_code); +bool options_is_operation(const options_t *const opts, + operation_id_t operation_id); +const options_backup_t *options_get_for_backup(const options_t *const opts); +const options_restore_t *options_get_for_restore(const options_t *const opts); #endif /* OPTIONS_H */ -- cgit v1.2.3