diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 19:09:19 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 19:09:19 -0400 |
| commit | c3e2e78121ac357ed7c617c29b8b342101ecf1e0 (patch) | |
| tree | 5ab0923f67d0c80d2954d9d86191d7a802952feb /src | |
| parent | 5bdf96234a388cbd3854747b0667620ebb60ccdf (diff) | |
Allow passing arguments with leading '-' using a backslash
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdlib/cli.c | 7 |
1 files changed, 7 insertions, 0 deletions
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")) { |
