From 320ed9ad22303d942cc6bb76df037044ce71b6ea Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 11 Jan 2023 13:44:37 -0800 Subject: main: move args to rototiller_t Particularly for simple boolean args it's desirable to just access their values directly in the args without any further cooking required. Rather than pointlessly duplicating those cases, just give visibility into the raw args. --- src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 970ca86..943a8ff 100644 --- a/src/main.c +++ b/src/main.c @@ -50,6 +50,7 @@ extern til_fb_ops_t sdl_fb_ops; static til_fb_ops_t *fb_ops; typedef struct rototiller_t { + til_args_t args; const til_module_t *module; til_module_context_t *module_context; pthread_t thread; @@ -348,26 +349,25 @@ int main(int argc, const char *argv[]) { const til_setting_desc_t *failed_desc = NULL; setup_t setup = {}; - til_args_t args = {}; int r; exit_if((r = til_init()) < 0, "unable to initialize libtil: %s", strerror(-r)); - exit_if(til_args_parse(argc, argv, &args) < 0, + exit_if(til_args_parse(argc, argv, &rototiller.args) < 0, "unable to process arguments"); - if (args.help) + if (rototiller.args.help) return print_help() < 0 ? EXIT_FAILURE : EXIT_SUCCESS; - exit_if((r = setup_from_args(&args, &setup, &failed_desc)) < 0, + exit_if((r = setup_from_args(&rototiller.args, &setup, &failed_desc)) < 0, "unable to use args%s%s%s: %s", failed_desc ? " for setting \"" : "", failed_desc ? failed_desc->key : "", failed_desc ? "\"" : "", strerror(-r)); - exit_if(r && print_setup_as_args(&setup, !args.gogogo) < 0, + exit_if(r && print_setup_as_args(&setup, !rototiller.args.gogogo) < 0, "unable to print setup"); exit_if(!(rototiller.module = til_lookup_module(til_settings_get_key(setup.module_settings, 0, NULL))), -- cgit v1.2.1