mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Move name and configKey values from widget to settings
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
const configKey = "cmdrunner"
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
|
||||
@@ -13,11 +15,11 @@ type Settings struct {
|
||||
cmd string
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.cmdrunner")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
|
||||
args: wtf.ToStrs(localConfig.UList("args")),
|
||||
cmd: localConfig.UString("cmd"),
|
||||
|
||||
@@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "CmdRunner", "cmdrunner", false),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
args: settings.args,
|
||||
cmd: settings.cmd,
|
||||
|
||||
Reference in New Issue
Block a user