gotools/cmd/yamltool/merge.go
2025-01-07 09:27:12 +01:00

31 lines
506 B
Go

package main
import (
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"os"
)
func mergeMap(yaml1 yaml.MapSlice, yaml2 yaml.MapSlice) yaml.MapSlice {
res := yaml1
//for key, item := range yaml2 {
// switch {
// case res.ToMap()[key] != nil && type
//
// }
//}
return res
}
func merge(cmd *cobra.Command, args []string) error {
res := make(yaml.MapSlice, 0)
for _, arg := range args {
config := parse(read(arg))
res = mergeMap(res, config)
}
encode(os.Stdout, res)
return nil
}