mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplify the inclusion of the Common config settings into each module
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -17,13 +17,13 @@ type colors struct {
|
||||
|
||||
type Settings struct {
|
||||
colors
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
}
|
||||
|
||||
settings.colors.name = ymlConfig.UString("colors.name", "red")
|
||||
|
||||
@@ -38,7 +38,7 @@ type ipinfo struct {
|
||||
// NewWidget constructor
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.common),
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
||||
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ const (
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
}
|
||||
|
||||
return &settings
|
||||
|
||||
@@ -32,7 +32,7 @@ type ipinfo struct {
|
||||
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.common),
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
||||
|
||||
settings: settings,
|
||||
}
|
||||
@@ -96,8 +96,8 @@ func (widget *Widget) setResult(info *ipinfo) {
|
||||
resultBuffer := new(bytes.Buffer)
|
||||
|
||||
err := resultTemplate.Execute(resultBuffer, map[string]string{
|
||||
"subheadingColor": widget.settings.common.Colors.Subheading,
|
||||
"valueColor": widget.settings.common.Colors.Text,
|
||||
"subheadingColor": widget.settings.Colors.Subheading,
|
||||
"valueColor": widget.settings.Colors.Text,
|
||||
"Ip": info.Ip,
|
||||
"Hostname": info.Hostname,
|
||||
"City": info.City,
|
||||
|
||||
Reference in New Issue
Block a user