1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

flag: fix panic if flag value was not provided (#6478)

This commit is contained in:
spaceface777
2020-09-25 15:31:35 +02:00
committed by GitHub
parent ae48b709ed
commit aa1d5fcbdd
2 changed files with 12 additions and 2 deletions

View File

@ -352,3 +352,13 @@ fn test_single_dash() {
flag_update := fp.bool('update', `u`, false, 'Update tools')
assert flag_update == false
}
fn test_optional_flags() {
mut fp := flag.new_flag_parser(['-a', '10', '-b'])
a := fp.int_opt('some-flag', `a`, '') or {
assert false
return
}
b := fp.string_opt('another-flag', `b`, '') or { 'some_default_value' }
assert b == 'some_default_value'
}