diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 15:58:02 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 15:58:02 -0400 |
| commit | 3ce1743d09011304ceec8366bba8604026096fb1 (patch) | |
| tree | 760f542c10968ae8655766a101430f48ac6c41b8 /src/stdlib/cli.h | |
| parent | 7e5a1fa68dbdc2aa034d9e22648837ef63e57d5e (diff) | |
Lazily initialize args
Diffstat (limited to 'src/stdlib/cli.h')
| -rw-r--r-- | src/stdlib/cli.h | 13 |
1 files changed, 5 insertions, 8 deletions
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); |
