goctl model reactor (#15)
* reactor sql generation * reactor sql generation * add console & example * optimize unit test & add document * modify default config * remove test file * Revert "remove test file" This reverts commit 81041f9e * fix stringx.go & optimize example * remove unused code
This commit is contained in:
58
tools/goctl/util/console/console.go
Normal file
58
tools/goctl/util/console/console.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
)
|
||||
|
||||
type (
|
||||
Console interface {
|
||||
Success(format string, a ...interface{})
|
||||
Warning(format string, a ...interface{})
|
||||
Error(format string, a ...interface{})
|
||||
}
|
||||
colorConsole struct {
|
||||
}
|
||||
// for idea log
|
||||
ideaConsole struct {
|
||||
}
|
||||
)
|
||||
|
||||
func NewColorConsole() *colorConsole {
|
||||
return &colorConsole{}
|
||||
}
|
||||
|
||||
func (c *colorConsole) Success(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Green(msg))
|
||||
}
|
||||
|
||||
func (c *colorConsole) Warning(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Yellow(msg))
|
||||
}
|
||||
|
||||
func (c *colorConsole) Error(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Red(msg))
|
||||
}
|
||||
|
||||
func NewIdeaConsole() *ideaConsole {
|
||||
return &ideaConsole{}
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Success(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println("[SUCCESS]: ", msg)
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Warning(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println("[WARNING]: ", msg)
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Error(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println("[ERROR]: ", msg)
|
||||
}
|
||||
Reference in New Issue
Block a user