From 558ff2dff088a12a3e178d3449de38eb64de61e9 Mon Sep 17 00:00:00 2001 From: chemotaxis Date: Wed, 16 Jun 2021 14:25:08 -0400 Subject: [PATCH] Skip authentication message if asking for help Currently, this still checks authentication, but we skip the authentication message and exit normally. --- cmd/gh/main.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/gh/main.go b/cmd/gh/main.go index 8f1efd77f..76bdc8d92 100644 --- a/cmd/gh/main.go +++ b/cmd/gh/main.go @@ -169,21 +169,18 @@ func mainRun() exitCode { cs := cmdFactory.IOStreams.ColorScheme() if cmd != nil && cmdutil.IsAuthCheckEnabled(cmd) && !cmdutil.CheckAuth(cfg) { - fmt.Fprintln(stderr, cs.Bold("Welcome to GitHub CLI!")) - fmt.Fprintln(stderr) - fmt.Fprintln(stderr, "To authenticate, please run `gh auth login`.") - // Print help only if you explicitly ask for help. lastArgument := expandedArgs[len(expandedArgs)-1] askingForHelp := lastArgument == "--help" || lastArgument == "-h" if askingForHelp { - fmt.Fprintln(stderr) - - helpHeading := fmt.Sprintf("Printing help for `%s`...\n", cmd.UseLine()) - fmt.Fprintf(stderr, cs.Bold(helpHeading)) - cmd.Help() + return exitOK } + + fmt.Fprintln(stderr, cs.Bold("Welcome to GitHub CLI!")) + fmt.Fprintln(stderr) + fmt.Fprintln(stderr, "To authenticate, please run `gh auth login`.") + return exitAuth }