mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cli: add pre_execute & post_execute
This commit is contained in:
@ -16,7 +16,9 @@ fn main() {
|
||||
mut greet_cmd := cli.Command{
|
||||
name: 'greet',
|
||||
description: 'Prints greeting in different languages',
|
||||
pre_execute: greet_pre_func,
|
||||
execute: greet_func,
|
||||
post_execute: greet_post_func,
|
||||
parent: 0
|
||||
}
|
||||
greet_cmd.add_flag(cli.Flag{
|
||||
@ -50,3 +52,11 @@ fn greet_func(cmd cli.Command) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn greet_pre_func(cmd cli.Command) {
|
||||
println('This is a function running before the main function')
|
||||
}
|
||||
|
||||
fn greet_post_func(cmd cli.Command) {
|
||||
println('This is a function running after the main function')
|
||||
}
|
Reference in New Issue
Block a user