diff options
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__}) |
