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

cli: allow flag to be set multi time (#8256)

This commit is contained in:
Emeric MARTINEAU
2021-01-22 18:03:02 +01:00
committed by GitHub
parent f2c6735d92
commit 081e3c46b4
5 changed files with 286 additions and 28 deletions

View File

@ -28,10 +28,17 @@ fn main() {
greet_cmd.add_flag(Flag{
flag: .int
name: 'times'
value: '3'
value: ['3']
description: 'Number of times the message gets printed.'
})
greet_cmd.add_flag(Flag{
flag: .string
name: 'fun'
multipe: true
description: 'Just a dumby flags to show multiple.'
})
cmd.add_command(greet_cmd)
cmd.setup()
cmd.parse(os.args)
}
@ -61,6 +68,12 @@ fn greet_func(cmd Command) {
}
}
}
fun := cmd.flags.get_strings('fun') or {
panic('Failed to get `fun` flag: $err')
}
for f in fun {
println('fun: ${f}')
}
}
fn greet_pre_func(cmd Command) {