From c3e2e78121ac357ed7c617c29b8b342101ecf1e0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 18 Oct 2025 19:09:19 -0400 Subject: Allow passing arguments with leading '-' using a backslash --- src/stdlib/cli.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/stdlib') diff --git a/src/stdlib/cli.c b/src/stdlib/cli.c index c3def8c0..47cac2e1 100644 --- a/src/stdlib/cli.c +++ b/src/stdlib/cli.c @@ -197,6 +197,13 @@ static List_t parse_arg_list(List_t args, const char *flag, void *dest, const Ty if (args.length == 0) print_err("No value provided for flag: ", flag); const char *arg = *(const char **)args.data; + + if ((type->tag == TextInfo || type == &CString$info) && arg[0] == '\\' && arg[1] == '-') { + arg = arg + 1; + } else if (arg[0] == '-' && !allow_dashes) { + print_err("Not a valid argument for flag ", flag, ": ", arg); + } + if (type->tag == OptionalInfo) { const TypeInfo_t *nonnull = type->OptionalInfo.type; if (streq(arg, "none")) { -- cgit v1.2.3