Make yamlfmt tool print filenames

Otherwise fixing errors YAML is much harder.
This commit is contained in:
Tim Hockin 2022-02-10 11:36:54 -08:00
parent f3654386ab
commit 722ebf8dca

View File

@ -18,6 +18,7 @@ package main
import (
"flag"
"fmt"
"io"
"os"
@ -32,19 +33,23 @@ func main() {
for _, path := range flag.Args() {
sourceYaml, err := os.ReadFile(path)
if err != nil {
panic(err)
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
}
rootNode, err := fetchYaml(sourceYaml)
if err != nil {
panic(err)
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
}
writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
panic(err)
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
}
err = streamYaml(writer, indent, rootNode)
if err != nil {
panic(err)
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
}
}
}