diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 18:20:20 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 18:20:20 -0400 |
| commit | 3779e7ccca177f8b9c3ccc4260f26f06fe7e8587 (patch) | |
| tree | 25e0a803ce9ec0d5927f963f076ecfbb056919b1 /src/stdlib | |
| parent | f77bcd8f5777824064088f03b06a1fc9bc2da8b0 (diff) | |
Support passing pointers to CLI args
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/cli.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stdlib/cli.c b/src/stdlib/cli.c index 8512d106..a82be076 100644 --- a/src/stdlib/cli.c +++ b/src/stdlib/cli.c @@ -248,6 +248,12 @@ static int64_t parse_arg_list(List_t args, const char *flag, void *dest, const T OptionalNum32_t parsed = Num32$parse(Text$from_str(arg), NULL); if (isnan(parsed)) print_err("Could not parse argument for --", flag, ": ", arg); *(Num32_t *)dest = parsed; + } else if (type->tag == PointerInfo) { + // For pointers, we can just allocate memory for the value and then parse the value + void *value = GC_MALLOC((size_t)type->PointerInfo.pointed->size); + n = parse_arg_list(args, flag, value, type->PointerInfo.pointed, allow_dashes); + *(void **)dest = value; + return n; } else if (type == &Path$info) { *(Path_t *)dest = Path$from_str(arg); } else if (type->tag == TextInfo) { |
