1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/cmdrunner/settings.go
Sean Smith 3a96c303a8 Allow duplicates of modules
This leverages the recent config changes, extending it so that config is literally using passed config, rather than
passed config value
Uses cmdRunner as an example for #181
Because config turns into a map, names are the root keys, and an optional type is provided
2019-04-30 23:33:59 -04:00

29 lines
546 B
Go

package cmdrunner
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/wtf"
)
const configKey = "cmdrunner"
type Settings struct {
common *cfg.Common
args []string
cmd string
}
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, moduleConfig, globalConfig),
args: wtf.ToStrs(moduleConfig.UList("args")),
cmd: moduleConfig.UString("cmd"),
}
return &settings
}