From ec2a5762b03356aa3b59714d51fd969e9bf3f6e3 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 1 Sep 2022 21:41:09 -0600 Subject: cmd: Don't print long help text on error --- cmd/cobra.go | 4 ++++ cmd/main.go | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/cobra.go b/cmd/cobra.go index 437fda9..d2a546c 100644 --- a/cmd/cobra.go +++ b/cmd/cobra.go @@ -91,6 +91,10 @@ https://caddyserver.com/docs/running $ caddy run --config caddy.json $ caddy reload --config caddy.json $ caddy stop`, + + // kind of annoying to have all the help text printed out if + // caddy has an error provisioning its modules, for instance... + SilenceUsage: true, } const fullDocsFooter = `Full documentation is available at: diff --git a/cmd/main.go b/cmd/main.go index 44e339a..b91559c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -51,12 +51,9 @@ func init() { // Main implements the main function of the caddy command. // Call this if Caddy is to be the main() of your program. func Main() { - switch len(os.Args) { - case 0: + if len(os.Args) == 0 { fmt.Printf("[FATAL] no arguments provided by OS; args[0] must be command\n") os.Exit(caddy.ExitCodeFailedStartup) - case 1: - os.Args = append(os.Args, "help") } if err := rootCmd.Execute(); err != nil { -- cgit v1.2.3