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

fix the cli module

This commit is contained in:
Alexander Medvednikov 2019-11-30 12:44:40 +03:00
parent 7e4799334f
commit 1a0b78ae2f

View File

@ -69,10 +69,10 @@ fn (flag mut Flag) parse_raw(args []string) ?[]string {
if args[0].len > flag.name.len && args[0].contains('=') { if args[0].len > flag.name.len && args[0].contains('=') {
println('1') println('1')
flag.value = args[0].split('=')[1] flag.value = args[0].split('=')[1]
return args.right(1) return args[1..]
} else if args.len >= 2 { } else if args.len >= 2 {
flag.value = args[1] flag.value = args[1]
return args.right(2) return args[2..]
} }
return error('missing argument for ${flag.name}') return error('missing argument for ${flag.name}')
} }
@ -80,15 +80,15 @@ fn (flag mut Flag) parse_raw(args []string) ?[]string {
fn (flag mut Flag) parse_bool(args []string) ?[]string { fn (flag mut Flag) parse_bool(args []string) ?[]string {
if args[0].len > flag.name.len && args[0].contains('=') { if args[0].len > flag.name.len && args[0].contains('=') {
flag.value = args[0].split('=')[1] flag.value = args[0].split('=')[1]
return args.right(1) return args[1..]
} else if args.len >= 2 { } else if args.len >= 2 {
if args[1] in ['true', 'false'] { if args[1] in ['true', 'false'] {
flag.value = args[1] flag.value = args[1]
return args.right(2) return args[2..]
} }
} }
flag.value = 'true' flag.value = 'true'
return args.right(1) return args[1..]
} }
fn (flags []Flag) get(name string) ?Flag { fn (flags []Flag) get(name string) ?Flag {