From 2f5ffbd60ad91820ac0c76d96aab174f9d9285b3 Mon Sep 17 00:00:00 2001 From: Nilesh Singh Date: Fri, 15 Jan 2021 13:28:57 +0530 Subject: [PATCH] Add fail message for non-existent hostname --- pkg/cmd/auth/status/status.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/cmd/auth/status/status.go b/pkg/cmd/auth/status/status.go index 59603981d..96ff458fc 100644 --- a/pkg/cmd/auth/status/status.go +++ b/pkg/cmd/auth/status/status.go @@ -81,11 +81,13 @@ func statusRun(opts *StatusOptions) error { apiClient := api.NewClientFromHTTP(httpClient) var failed bool + var isHostnameFound bool for _, hostname := range hostnames { if opts.Hostname != "" && opts.Hostname != hostname { continue } + isHostnameFound = true token, tokenSource, _ := cfg.GetWithSource(hostname, "oauth_token") tokenIsWriteable := cfg.CheckWriteable(hostname, "oauth_token") == nil @@ -139,6 +141,12 @@ func statusRun(opts *StatusOptions) error { // not to since I wanted this command to be read-only. } + if !isHostnameFound { + fmt.Fprintf(stderr, + "You are not logged into any GitHub hosts. Run %s to authenticate.\n", cs.Bold(fmt.Sprintf("gh auth login -h %s", opts.Hostname))) + return cmdutil.SilentError + } + for _, hostname := range hostnames { lines, ok := statusInfo[hostname] if !ok {