Skip to content

Commit 4ca576d

Browse files
committed
Don't print usage help when a config file couldn't be parsed
Fixes #291 Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent fdd4338 commit 4ca576d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/root/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ We collect anonymous usage data to help improve cagent. To disable:
143143
fmt.Fprintln(os.Stderr, "\nEither:\n - Set those environment variables before running cagent\n - Run cagent with --env-from-file\n - Store those secrets using one of the built-in environment variable providers.")
144144
} else {
145145
fmt.Fprintln(os.Stderr, err)
146-
_ = rootCmd.Usage()
146+
fmt.Fprintln(os.Stderr)
147+
if strings.HasPrefix(err.Error(), "unknown command ") || strings.HasPrefix(err.Error(), "accepts ") {
148+
_ = rootCmd.Usage()
149+
}
147150
}
148151

149152
os.Exit(1)

0 commit comments

Comments
 (0)