added yamltool sort
This commit is contained in:
+5
-11
@@ -6,18 +6,8 @@ import (
|
||||
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"os"
|
||||
)
|
||||
|
||||
func read(file string) []byte {
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func parse(data []byte) (yaml.MapSlice, error) {
|
||||
var result yaml.MapSlice
|
||||
decoder := yaml.NewDecoder(bytes.NewReader(data),
|
||||
@@ -31,7 +21,11 @@ func parse(data []byte) (yaml.MapSlice, error) {
|
||||
|
||||
func parseFiles(cmd *cobra.Command, args []string) error {
|
||||
for _, arg := range args {
|
||||
_, err := parse(read(arg))
|
||||
data, err := read(arg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = parse(data)
|
||||
if err != nil {
|
||||
fmt.Printf("%s: %v\n", arg, err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user