mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
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
29 lines
546 B
Go
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
|
|
}
|