yanic/output/meshviewer-ffrgb/output.go

43 lines
729 B
Go
Raw Permalink Normal View History

package meshviewerFFRGB
import (
"errors"
"github.com/FreifunkBremen/yanic/output"
"github.com/FreifunkBremen/yanic/runtime"
)
type Output struct {
output.Output
path string
}
type Config map[string]interface{}
func (c Config) Path() string {
if path, ok := c["path"]; ok {
return path.(string)
}
return ""
}
func init() {
output.RegisterAdapter("meshviewer-ffrgb", Register)
}
func Register(configuration map[string]interface{}) (output.Output, error) {
2022-03-28 03:56:00 +02:00
config := Config(configuration)
if path := config.Path(); path != "" {
return &Output{
path: path,
}, nil
}
return nil, errors.New("no path given")
}
func (o *Output) Save(nodes *runtime.Nodes) {
runtime.SaveJSON(transform(nodes), o.path)
}