portainer-devtool/go/utils/print.go

88 lines
1.9 KiB
Go
Raw Permalink Normal View History

package utils
import (
"fmt"
)
const (
colorReset string = "\033[0m"
colorRed string = "\033[31m"
colorGreen string = "\033[32m"
colorYellow string = "\033[33m"
colorBlue string = "\033[34m"
colorPurple string = "\033[35m"
colorCyan string = "\033[36m"
colorWhite string = "\033[37m"
)
func PrintOutput(message string, output []byte) {
if message != "" {
HighlightPrint(message)
}
fmt.Println(string(output))
}
func HighlightPrint(message string) {
fmt.Println()
fmt.Println(colorBlue, message, colorReset)
}
func SuccessPrint(message string) {
fmt.Println()
fmt.Println(colorGreen, message, colorReset)
}
func ErrorPrint(message string) {
fmt.Println()
fmt.Println(colorRed, message, colorReset)
}
func WarnPrint(message string) {
fmt.Println()
fmt.Println(colorPurple, message, colorReset)
}
func InputPrint(message string) {
2022-12-25 22:53:51 +11:00
// adding \n before setting colorful output can
// remove the first space in the colorful output
fmt.Println()
fmt.Println(colorYellow, message, colorReset)
}
2022-12-25 22:53:51 +11:00
func PrintMenu(question string, taskNames []string) {
if question != "" {
InputPrint(fmt.Sprintf("[%s]", question))
}
2022-12-25 22:53:51 +11:00
// adding \n before setting colorful output can
// remove the first space in the colorful output
menuContent := "\n"
2022-12-25 22:53:51 +11:00
for i, name := range taskNames {
menuContent += fmt.Sprintf("%d. %s\n", i+1, name)
}
fmt.Println(colorCyan, menuContent, colorReset)
}
func MenuPrint(question, menu string) {
if question != "" {
InputPrint(fmt.Sprintf("[%s]", question))
}
// menu := `
// 1. Build Portainer EE/CE All
// 2. Build Portainer EE/CE Frontend
// 3. Build Portainer EE/CE Backend
// 4. Generate Portainer EE/CE JWT
// 5. Run Before Commit [Portainer EE/CE]
// 6. Get Portainer CE API Reference
// 7. Run Before Commit [k8s]
// 8. Build Portainer Agent
// 9. Cleanup Temporary Volume
// `
fmt.Println(colorCyan, menu, colorReset)
}