aboutsummaryrefslogtreecommitdiff
path: root/core/flags
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-14 23:59:01 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-14 23:59:01 -0400
commitc3acdeb310c1426d009004956c1b3e59e4920808 (patch)
treedc0b95af9c9789bdc6d2ac17dea0cc1ad9da42b5 /core/flags
parentedb685f04be9aef407dc8abac7bb76fb51184f9f (diff)
Add `--` parsing to UNIX-style `core:flags`
This will allow a user to indicate all arguments after `--` are parsed into the variadic array.
Diffstat (limited to 'core/flags')
-rw-r--r--core/flags/internal_parsing.odin8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/flags/internal_parsing.odin b/core/flags/internal_parsing.odin
index 349afdd29..7a769b17c 100644
--- a/core/flags/internal_parsing.odin
+++ b/core/flags/internal_parsing.odin
@@ -90,6 +90,14 @@ parse_one_unix_arg :: proc(model: ^$T, parser: ^Parser, arg: string) -> (
if strings.has_prefix(arg, "-") {
// Allow `--` to function as `-`.
arg = arg[1:]
+
+ if len(arg) == 0 {
+ // `--`, and only `--`.
+ // Everything from now on will be treated as an argument.
+ future_args = max(int)
+ current_flag = INTERNAL_VARIADIC_FLAG
+ return
+ }
}
flag: string