diff options
| author | Jan Sucan <jan@jansucan.com> | 2022-06-18 08:50:45 +0200 |
|---|---|---|
| committer | Jan Sucan <jan@jansucan.com> | 2022-06-18 08:50:54 +0200 |
| commit | 948a65cf39c8ce31c5adc0f24979e0cb55bc33c3 (patch) | |
| tree | ae923f4594fef0abb777f63291d62530c345b229 /src/options.h | |
| parent | e1d10bea5d9fc94ba800ade1de430c7f3c0ccacd (diff) | |
Refactor the command line interface
Select operation by its name instead of by number of the arguments.
Diffstat (limited to 'src/options.h')
| -rw-r--r-- | src/options.h | 26 |
1 files changed, 23 insertions, 3 deletions
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 <stdbool.h> #include <stdint.h> 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 */ |
