Skip to content

Commit

Permalink
fix -help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
losisin committed Oct 30, 2023
1 parent 311748a commit 6563be2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ func parseFlags(progname string, args []string) (config *Config, output string,
flags.StringVar(&conf.outputPath, "output", "values.schema.json", "Output file path")
flags.IntVar(&conf.draft, "draft", 2020, "Draft version (4, 6, 7, 2019, or 2020)")

// flags.Usage = func() {
// fmt.Println("usage: helm schema [-input STR] [-draft INT] [-output STR]")
// flags.PrintDefaults()
// }

err = flags.Parse(args)
if err != nil {
fmt.Fprintln(os.Stderr, "usage: helm schema [-input STR] [-draft INT] [-output STR]")
fmt.Println("usage: helm schema [-input STR] [-draft INT] [-output STR]")
return nil, buf.String(), err
}

Expand Down Expand Up @@ -171,8 +176,8 @@ func generateJsonSchema(config *Config) {
func main() {
conf, output, err := parseFlags(os.Args[0], os.Args[1:])
if err == flag.ErrHelp {
fmt.Println("output:", output)
os.Exit(2)
fmt.Println(output)
os.Exit(0)
} else if err != nil {
fmt.Println("got error:", err)
fmt.Println("output:\n", output)
Expand Down

0 comments on commit 6563be2

Please sign in to comment.