vlib: cli errors now print in red

Signed-off-by: Hunam <hunam@disroot.org>
pull/13647/head
Hunam 2022-03-03 19:51:11 +01:00 committed by Delyan Angelov
parent f70e5bd69b
commit e178fba3ec
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 5 additions and 3 deletions

View File

@ -1,5 +1,7 @@
module cli
import term
type FnCommandCallback = fn (cmd Command) ?
// str returns the `string` representation of the callback.
@ -228,19 +230,19 @@ fn (mut cmd Command) parse_commands() {
cmd.check_required_flags()
if !isnil(cmd.pre_execute) {
cmd.pre_execute(*cmd) or {
eprintln('cli preexecution error: $err')
eprintln('${term.bright_red('cli preexecution error:')} $err')
exit(1)
}
}
if !isnil(cmd.execute) {
cmd.execute(*cmd) or {
eprintln('cli execution error: $err')
eprintln('${term.bright_red('cli execution error:')} $err')
exit(1)
}
}
if !isnil(cmd.post_execute) {
cmd.post_execute(*cmd) or {
eprintln('cli postexecution error: $err')
eprintln('${term.bright_red('cli postexecution error:')} $err')
exit(1)
}
}