31 lines
506 B
Go
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
|
||
|
}
|