go-scopes/config/config.go

53 lines
778 B
Go

package config
import "git.sr.ht/~cco/go-scopes/common"
type Cfg struct {
*Base
ConfigFormat string
}
func Start(ctx common.Context) {
}
// definitions
type Config interface {
Name() string
Starter() common.StartFct
Children() []Config
Add(Config)
}
type Base struct {
name string
starter common.StartFct
children []Config
}
func (cfg *Base) Name() string {
return cfg.name
}
func (cfg *Base) Starter() common.StartFct {
return cfg.starter
}
func (cfg *Base) Children() []Config {
return cfg.children
}
func (cfg *Base) Add(child Config) {
cfg.children = append(cfg.children, child)
}
func MakeBase(name string, starter common.StartFct) *Base {
return &Base{
name: name,
starter: starter,
}
}
func Setup(cfg Config) Config {
return cfg
}