forked from elastos/Elastos.ELA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.go
33 lines (26 loc) · 728 Bytes
/
print.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package common
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func PrintError(c *cli.Context, err error, cmd string) {
fmt.Println("Incorrect Usage:", err)
fmt.Println("")
cli.ShowCommandHelp(c, cmd)
}
func PrintErrorMsg(format string, a ...interface{}) {
format = fmt.Sprintf("\033[31m[ERROR] %s\033[0m\n", format) //Print error msg with red color
fmt.Printf(format, a...)
}
func PrintWarnMsg(format string, a ...interface{}) {
format = fmt.Sprintf("\033[33m[WARN] %s\033[0m\n", format) //Print error msg with yellow color
fmt.Printf(format, a...)
}
func PrintInfoMsg(format string, a ...interface{}) {
fmt.Printf(format+"\n", a...)
}
func PrintErrorAndExit(errMsg string) {
fmt.Println(errMsg)
os.Exit(1)
}