1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 System extracted to new config format

This commit is contained in:
Chris Cummer 2019-04-16 09:09:42 -07:00
parent 5f07cb6db4
commit ea88f5eece
3 changed files with 26 additions and 5 deletions

View File

@ -286,7 +286,8 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
settings := status.NewSettingsFromYAML(wtf.Config)
widget = status.NewWidget(app, settings)
case "system":
widget = system.NewWidget(app, date, version)
settings := system.NewSettingsFromYAML(wtf.Config)
widget = system.NewWidget(app, date, version, settings)
case "textfile":
widget = textfile.NewWidget(app, pages)
case "todo":

View File

@ -0,0 +1,18 @@
package system
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
}
return &settings
}

View File

@ -11,17 +11,19 @@ import (
type Widget struct {
wtf.TextWidget
systemInfo *SystemInfo
Date string
Version string
settings *Settings
systemInfo *SystemInfo
}
func NewWidget(app *tview.Application, date, version string) *Widget {
func NewWidget(app *tview.Application, date, version string, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, "System", "system", false),
Date: date,
Version: version,
Date: date,
settings: settings,
Version: version,
}
widget.systemInfo = NewSystemInfo()