mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cli: ensure that required flags are set (#8826)
This commit is contained in:
@ -32,17 +32,17 @@ fn main() {
|
||||
description: 'Number of times the message gets printed.'
|
||||
})
|
||||
greet_cmd.add_flag(Flag{
|
||||
flag: .string
|
||||
name: 'fun'
|
||||
multiple: true
|
||||
description: 'Just a dumby flags to show multiple.'
|
||||
flag: .string
|
||||
name: 'fun'
|
||||
multiple: true
|
||||
description: 'Just a dumby flags to show multiple.'
|
||||
})
|
||||
cmd.add_command(greet_cmd)
|
||||
cmd.setup()
|
||||
cmd.parse(os.args)
|
||||
}
|
||||
|
||||
fn greet_func(cmd Command) {
|
||||
fn greet_func(cmd Command) ? {
|
||||
language := cmd.flags.get_string('language') or {
|
||||
panic('Failed to get `language` flag: $err')
|
||||
}
|
||||
@ -76,10 +76,10 @@ fn greet_func(cmd Command) {
|
||||
}
|
||||
}
|
||||
|
||||
fn greet_pre_func(cmd Command) {
|
||||
fn greet_pre_func(cmd Command) ? {
|
||||
println('This is a function running before the main function.\n')
|
||||
}
|
||||
|
||||
fn greet_post_func(cmd Command) {
|
||||
fn greet_post_func(cmd Command) ? {
|
||||
println('\nThis is a function running after the main function.')
|
||||
}
|
||||
|
Reference in New Issue
Block a user