helm-schema-2-doc/main.go

47 lines
921 B
Go

package main
import (
"flag"
"fmt"
"os"
jsp "gitlab.com/CRThaze/helm-schema-2-doc/parser"
)
type repeatStringFlag []string
func (r *repeatStringFlag) String() string {
return ""
}
func (r *repeatStringFlag) Set(value string) error {
*r = append(*r, value)
return nil
}
var flags struct {
output string
skip repeatStringFlag
}
func init() {
flag.StringVar(&flags.output, "o", "values.md", "The output file to write the resulting documentation.")
flag.Var(&flags.skip, "s", "Values to omit from the output, in the format '.Value.name'. Can be used multiple times.")
flag.Parse()
}
func main() {
valuesSet, err := jsp.ParseSchemaFile()
if err != nil {
fmt.Printf("ERROR: %+v\n", err)
os.Exit(1)
}
for _, toSkip := range flags.skip {
delete(valuesSet, toSkip)
}
if err := os.WriteFile(flags.output, valuesSet.Render(), 0644); err != nil {
fmt.Printf("ERROR: %+v\n", err)
os.Exit(1)
}
}