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