mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Add warning log
This commit is contained in:
42
cli/packages/util/log.go
Normal file
42
cli/packages/util/log.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func HandleError(err error, messages ...string) {
|
||||
PrintErrorAndExit(1, err, messages...)
|
||||
}
|
||||
|
||||
func PrintErrorAndExit(exitCode int, err error, messages ...string) {
|
||||
printError(err)
|
||||
|
||||
if len(messages) > 0 {
|
||||
for _, message := range messages {
|
||||
fmt.Println(message)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
||||
func PrintWarning(message string) {
|
||||
color.Yellow("Warning: %v", message)
|
||||
}
|
||||
|
||||
func PrintMessageAndExit(messages ...string) {
|
||||
if len(messages) > 0 {
|
||||
for _, message := range messages {
|
||||
fmt.Println(message)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func printError(e error) {
|
||||
color.Red("Hmm, we ran into an error: %v", e)
|
||||
}
|
||||
Reference in New Issue
Block a user