mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 05:11:29 +08:00
Made init less verbose
This commit is contained in:
parent
12dec650de
commit
aaa425724c
38
cmd/log.go
38
cmd/log.go
@ -9,52 +9,88 @@ import (
|
||||
|
||||
// Logger struct
|
||||
type Logger struct {
|
||||
errorOnly bool
|
||||
}
|
||||
|
||||
// NewLogger creates a new logger!
|
||||
func NewLogger() *Logger {
|
||||
return &Logger{}
|
||||
return &Logger{errorOnly: false}
|
||||
}
|
||||
|
||||
func (l *Logger) SetErrorOnly(errorOnly bool) {
|
||||
l.errorOnly = errorOnly
|
||||
}
|
||||
|
||||
// Yellow - Outputs yellow text
|
||||
func (l *Logger) Yellow(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
color.New(color.FgHiYellow).PrintfFunc()(format+"\n", a...)
|
||||
}
|
||||
|
||||
// Yellowf - Outputs yellow text without the newline
|
||||
func (l *Logger) Yellowf(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
color.New(color.FgHiYellow).PrintfFunc()(format, a...)
|
||||
}
|
||||
|
||||
// Green - Outputs Green text
|
||||
func (l *Logger) Green(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
color.New(color.FgHiGreen).PrintfFunc()(format+"\n", a...)
|
||||
}
|
||||
|
||||
// White - Outputs White text
|
||||
func (l *Logger) White(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
color.New(color.FgHiWhite).PrintfFunc()(format+"\n", a...)
|
||||
}
|
||||
|
||||
// WhiteUnderline - Outputs White text with underline
|
||||
func (l *Logger) WhiteUnderline(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
l.White(format, a...)
|
||||
l.White(l.underline(format))
|
||||
}
|
||||
|
||||
// YellowUnderline - Outputs Yellow text with underline
|
||||
func (l *Logger) YellowUnderline(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
l.Yellow(format, a...)
|
||||
l.Yellow(l.underline(format))
|
||||
}
|
||||
|
||||
// underline returns a string of a line, the length of the message given to it
|
||||
func (l *Logger) underline(message string) string {
|
||||
if l.errorOnly {
|
||||
return ""
|
||||
}
|
||||
|
||||
return strings.Repeat("-", len(message))
|
||||
}
|
||||
|
||||
// Red - Outputs Red text
|
||||
func (l *Logger) Red(format string, a ...interface{}) {
|
||||
if l.errorOnly {
|
||||
return
|
||||
}
|
||||
|
||||
color.New(color.FgHiRed).PrintfFunc()(format+"\n", a...)
|
||||
}
|
||||
|
||||
|
@ -220,6 +220,13 @@ func (sc *SystemConfig) load(filename string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CheckDependenciesSilent(logger *Logger) (bool, error) {
|
||||
logger.SetErrorOnly(true)
|
||||
result, err := CheckDependencies(logger)
|
||||
logger.SetErrorOnly(false)
|
||||
return result, err
|
||||
}
|
||||
|
||||
// CheckDependencies will look for Wails dependencies on the system
|
||||
// Errors are reported in error and the bool return value is whether
|
||||
// the dependencies are all installed.
|
||||
@ -281,6 +288,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.White("")
|
||||
|
||||
return !errors, err
|
||||
}
|
||||
|
@ -34,13 +34,11 @@ Any flags that are required and not given will be prompted for.`
|
||||
return err
|
||||
}
|
||||
|
||||
success, err := cmd.CheckDependencies(logger)
|
||||
success, err := cmd.CheckDependenciesSilent(logger)
|
||||
if !success {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.White("")
|
||||
|
||||
// Do we want to just force defaults?
|
||||
if projectOptions.UseDefaults {
|
||||
// Use defaults
|
||||
|
Loading…
Reference in New Issue
Block a user