mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 CmdRunner extracted to new config format
This commit is contained in:
parent
37356679cc
commit
73e0e18ebc
3
main.go
3
main.go
@ -199,7 +199,8 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
|
|||||||
cfg := clocks.NewSettingsFromYAML(wtf.Config)
|
cfg := clocks.NewSettingsFromYAML(wtf.Config)
|
||||||
widget = clocks.NewWidget(app, cfg)
|
widget = clocks.NewWidget(app, cfg)
|
||||||
case "cmdrunner":
|
case "cmdrunner":
|
||||||
widget = cmdrunner.NewWidget(app)
|
cfg := cmdrunner.NewSettingsFromYAML(wtf.Config)
|
||||||
|
widget = cmdrunner.NewWidget(app, cfg)
|
||||||
case "cryptolive":
|
case "cryptolive":
|
||||||
widget = cryptolive.NewWidget(app)
|
widget = cryptolive.NewWidget(app)
|
||||||
case "datadog":
|
case "datadog":
|
||||||
|
@ -2,7 +2,6 @@ package bamboohr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
// "os"
|
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/wtfutil/wtf/wtf"
|
"github.com/wtfutil/wtf/wtf"
|
||||||
|
@ -2,7 +2,6 @@ package circleci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
// "os"
|
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/wtfutil/wtf/wtf"
|
"github.com/wtfutil/wtf/wtf"
|
||||||
|
27
modules/cmdrunner/settings.go
Normal file
27
modules/cmdrunner/settings.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package cmdrunner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/olebedev/config"
|
||||||
|
"github.com/wtfutil/wtf/cfg"
|
||||||
|
"github.com/wtfutil/wtf/wtf"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Settings struct {
|
||||||
|
common *cfg.Common
|
||||||
|
|
||||||
|
args []string
|
||||||
|
cmd string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||||
|
localConfig, _ := ymlConfig.Get("wtf.mods.cmdrunner")
|
||||||
|
|
||||||
|
settings := Settings{
|
||||||
|
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||||
|
|
||||||
|
args: wtf.ToStrs(wtf.Config.UList("args")),
|
||||||
|
cmd: localConfig.UString("cmd"),
|
||||||
|
}
|
||||||
|
|
||||||
|
return &settings
|
||||||
|
}
|
@ -15,14 +15,16 @@ type Widget struct {
|
|||||||
args []string
|
args []string
|
||||||
cmd string
|
cmd string
|
||||||
result string
|
result string
|
||||||
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application) *Widget {
|
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(app, "CmdRunner", "cmdrunner", false),
|
TextWidget: wtf.NewTextWidget(app, "CmdRunner", "cmdrunner", false),
|
||||||
|
|
||||||
args: wtf.ToStrs(wtf.Config.UList("wtf.mods.cmdrunner.args")),
|
args: settings.args,
|
||||||
cmd: wtf.Config.UString("wtf.mods.cmdrunner.cmd"),
|
cmd: settings.cmd,
|
||||||
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user