Skip to content

Commit

Permalink
Fix usage of -h
Browse files Browse the repository at this point in the history
  • Loading branch information
yannh committed Mar 8, 2021
1 parent 19441d8 commit a5a3467
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions acceptance.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
4 changes: 3 additions & 1 deletion cmd/kubeconform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a5a3467

Please sign in to comment.