Skip to content

Commit a5a3467

Browse files
committed
Fix usage of -h
1 parent 19441d8 commit a5a3467

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

acceptance.bats

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ resetCacheFolder() {
55
mkdir -p cache
66
}
77

8+
@test "Pass when displaying help with -h" {
9+
run bin/kubeconform -h
10+
[ "$status" -eq 0 ]
11+
[ "${lines[0]}" == 'Usage: bin/kubeconform [OPTION]... [FILE OR FOLDER]...' ]
12+
}
13+
814
@test "Pass when parsing a valid Kubernetes config YAML file" {
915
run bin/kubeconform -summary fixtures/valid.yaml
1016
[ "$status" -eq 0 ]

cmd/kubeconform/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func processResults(cancel context.CancelFunc, o output.Output, validationResult
4646

4747
func realMain() int {
4848
cfg, out, err := config.FromFlags(os.Args[0], os.Args[1:])
49-
if out != "" {
49+
if cfg.Help {
50+
return 0
51+
} else if out != "" {
5052
fmt.Println(out)
5153
return 1
5254
} else if err != nil {

0 commit comments

Comments
 (0)