From 3ce1743d09011304ceec8366bba8604026096fb1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 18 Oct 2025 15:58:02 -0400 Subject: Lazily initialize args --- src/stdlib/cli.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/stdlib/cli.h') diff --git a/src/stdlib/cli.h b/src/stdlib/cli.h index 596409c1..5026edb3 100644 --- a/src/stdlib/cli.h +++ b/src/stdlib/cli.h @@ -9,17 +9,14 @@ typedef struct { const char *name; - char short_flag; - bool required; - const TypeInfo_t *type; void *dest; + const TypeInfo_t *type; + char short_flag; + bool required, populated; } cli_arg_t; -void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, const char *version, int spec_len, - cli_arg_t spec[spec_len]); -#define tomo_parse_args(argc, argv, usage, help, version, ...) \ - _tomo_parse_args(argc, argv, usage, help, version, sizeof((cli_arg_t[]){__VA_ARGS__}) / sizeof(cli_arg_t), \ - (cli_arg_t[]){__VA_ARGS__}) +void tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, const char *version, int spec_len, + cli_arg_t spec[spec_len]); bool pop_cli_flag(List_t *args, char short_flag, const char *flag, void *dest, const TypeInfo_t *type); bool pop_cli_positional(List_t *args, const char *flag, void *dest, const TypeInfo_t *type, bool allow_dashes); -- cgit v1.2.3