// Command frontmatterlint reports markdown notes whose YAML frontmatter does // not parse, and optionally repairs the ones that only need quoting. // // go run ./cmd/frontmatterlint ../../brain # report // go run ./cmd/frontmatterlint -fix ../../brain # repair in place // // Exit codes: 0 clean (or everything repaired), 1 findings remain, 2 the scan // itself failed. package main import ( "flag" "fmt" "os" "github.com/mathiasbq/hyperguild/ingestion/internal/frontmatter" ) func main() { fix := flag.Bool("fix", false, "repair files that quoting can rescue, in place") flag.Parse() root := "." if flag.NArg() > 0 { root = flag.Arg(0) } findings, err := frontmatter.Scan(root, *fix) if err != nil { fmt.Fprintln(os.Stderr, "frontmatterlint:", err) os.Exit(2) } var unresolved int for _, f := range findings { if f.Repaired { fmt.Printf("repaired %s\n", f.Path) continue } unresolved++ fmt.Printf("BROKEN %s: %v\n", f.Path, f.Err) } if unresolved > 0 { fmt.Fprintf(os.Stderr, "\n%d file(s) with unparseable frontmatter", unresolved) if !*fix { fmt.Fprint(os.Stderr, " — re-run with -fix") } fmt.Fprintln(os.Stderr) os.Exit(1) } fmt.Printf("✓ frontmatter: %d file(s) repaired, none broken\n", len(findings)) }