Fix usage of -h

This commit is contained in:
Yann Hamon 2021-03-08 18:14:24 +01:00
parent 19441d8182
commit a5a34675c0
2 changed files with 9 additions and 1 deletions

View file

@ -5,6 +5,12 @@ resetCacheFolder() {
mkdir -p cache
}
@test "Pass when displaying help with -h" {
run bin/kubeconform -h
[ "$status" -eq 0 ]
[ "${lines[0]}" == 'Usage: bin/kubeconform [OPTION]... [FILE OR FOLDER]...' ]
}
@test "Pass when parsing a valid Kubernetes config YAML file" {
run bin/kubeconform -summary fixtures/valid.yaml
[ "$status" -eq 0 ]

View file

@ -46,7 +46,9 @@ func processResults(cancel context.CancelFunc, o output.Output, validationResult
func realMain() int {
cfg, out, err := config.FromFlags(os.Args[0], os.Args[1:])
if out != "" {
if cfg.Help {
return 0
} else if out != "" {
fmt.Println(out)
return 1
} else if err != nil {