diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 15:34:18 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 15:34:18 -0400 |
| commit | f775d6602989eec9d37deb16979922004a77a70c (patch) | |
| tree | 866eee67d5800202575ffb401c750bef253dc1dc /src/stdlib/cli.h | |
| parent | b025a65b45e8f2e8a56eb087743f9e9e7109b9f8 (diff) | |
| parent | 64fe11554a0aeea1f176116a2a483c623d4cf60a (diff) | |
Merge branch 'main' into formatter
Diffstat (limited to 'src/stdlib/cli.h')
| -rw-r--r-- | src/stdlib/cli.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/stdlib/cli.h b/src/stdlib/cli.h new file mode 100644 index 00000000..a2058754 --- /dev/null +++ b/src/stdlib/cli.h @@ -0,0 +1,21 @@ +// Command line argument parsing + +#pragma once + +#include <stdbool.h> + +#include "datatypes.h" +#include "types.h" + +typedef struct { + const char *name; + bool required; + const TypeInfo_t *type; + void *dest; +} 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__}) |
