Improve help

This commit is contained in:
Yann Hamon 2020-10-18 19:43:43 +02:00
parent 9e4d9f9ca4
commit b3b16ceccc
2 changed files with 13 additions and 2 deletions

View file

@ -217,7 +217,7 @@ func getFiles(files []string, fileBatches chan []string, validationResults chan
func realMain() int { func realMain() int {
var schemaLocationsParam arrayParam var schemaLocationsParam arrayParam
var skipKindsCSV, k8sVersion, outputFormat string var skipKindsCSV, k8sVersion, outputFormat string
var summary, strict, verbose, ignoreMissingSchemas bool var summary, strict, verbose, ignoreMissingSchemas, help bool
var nWorkers int var nWorkers int
var err error var err error
var files []string var files []string
@ -231,8 +231,19 @@ func realMain() int {
flag.BoolVar(&strict, "strict", false, "disallow additional properties not in schema") flag.BoolVar(&strict, "strict", false, "disallow additional properties not in schema")
flag.StringVar(&outputFormat, "output", "text", "output format - text, json") flag.StringVar(&outputFormat, "output", "text", "output format - text, json")
flag.BoolVar(&verbose, "verbose", false, "print results for all resources") flag.BoolVar(&verbose, "verbose", false, "print results for all resources")
flag.BoolVar(&help, "h", false, "show help information")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE OR FOLDER]...\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse() flag.Parse()
if help {
flag.Usage()
return 1
}
skipKinds := skipKindsMap(skipKindsCSV) skipKinds := skipKindsMap(skipKindsCSV)
for _, file := range flag.Args() { for _, file := range flag.Args() {

View file

@ -61,7 +61,7 @@ func (o *jsono) Write(filename, kind, name, version string, err error, skipped b
case EMPTY: case EMPTY:
} }
if o.verbose || (s != VALID && s != SKIPPED && s != EMPTY ) { if o.verbose || (s != VALID && s != SKIPPED && s != EMPTY) {
o.results = append(o.results, result{Filename: filename, Kind: kind, Name: name, Version: version, Status: st, Msg: msg}) o.results = append(o.results, result{Filename: filename, Kind: kind, Name: name, Version: version, Status: st, Msg: msg})
} }