mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
flag: fix panic on single -
This commit is contained in:
parent
72ecc222ee
commit
fb45e2e046
@ -176,7 +176,7 @@ fn (mut fs FlagParser) parse_bool_value(longhand string, shorthand byte) ?string
|
||||
fs.args.delete(i)
|
||||
return val
|
||||
}
|
||||
if arg[0] == `-` && arg[1] != `-` && arg.index_byte(shorthand) != -1 {
|
||||
if arg.len > 1 && arg[0] == `-` && arg[1] != `-` && arg.index_byte(shorthand) != -1 {
|
||||
// -abc is equivalent to -a -b -c
|
||||
return 'true'
|
||||
}
|
||||
|
@ -344,3 +344,11 @@ fn test_long_options_that_start_with_the_same_letter_as_another_short_option_bot
|
||||
assert verbose == true
|
||||
assert vabc == '/abc'
|
||||
}
|
||||
|
||||
fn test_single_dash() {
|
||||
mut fp := flag.new_flag_parser([
|
||||
'-'
|
||||
])
|
||||
flag_update := fp.bool('update', `u`, false, 'Update tools')
|
||||
assert flag_update == false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user