diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-15 00:18:49 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-15 00:24:59 -0400 |
| commit | 76575e834b9fd523179071340f794a8a1dcb3638 (patch) | |
| tree | 57727ae87fe1cedb3bd92c3dd2dee5e85b4b11ae /core/flags | |
| parent | 42a5a2cf17e4547ff6bce445ef82404486e3b714 (diff) | |
Raise error on spaced UNIX-style flag with no value
Diffstat (limited to 'core/flags')
| -rw-r--r-- | core/flags/parsing.odin | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/flags/parsing.odin b/core/flags/parsing.odin index d8aea513f..f09c4c690 100644 --- a/core/flags/parsing.odin +++ b/core/flags/parsing.odin @@ -1,6 +1,7 @@ package flags import "core:container/bit_array" +import "core:fmt" Parsing_Style :: enum { // Odin-style: `-flag`, `-flag:option`, `-map:key=value` @@ -71,9 +72,15 @@ parse :: proc( return } - for /**/; future_args > 0; future_args -= 1 { + for starting_future_args := future_args; future_args > 0; future_args -= 1 { i += 1 if i == len(args) { + if future_args == starting_future_args { + return Parse_Error { + .No_Value, + fmt.tprintf("Expected a value for `%s` but none was given.", current_flag), + } + } break } #no_bounds_check arg = args[i] |