From 530b91d9e756830abffce9d96ed995e0fe3302b0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 31 Aug 2025 12:58:59 -0400 Subject: Move CLI parsing to its own file. --- src/stdlib/cli.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/stdlib/cli.h (limited to 'src/stdlib/cli.h') 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 + +#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__}) -- cgit v1.2.3