Skip to content

Commit 2f5ffbd

Browse files
committed
Add fail message for non-existent hostname
1 parent 4750e4a commit 2f5ffbd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/cmd/auth/status/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ func statusRun(opts *StatusOptions) error {
8181
apiClient := api.NewClientFromHTTP(httpClient)
8282

8383
var failed bool
84+
var isHostnameFound bool
8485

8586
for _, hostname := range hostnames {
8687
if opts.Hostname != "" && opts.Hostname != hostname {
8788
continue
8889
}
90+
isHostnameFound = true
8991

9092
token, tokenSource, _ := cfg.GetWithSource(hostname, "oauth_token")
9193
tokenIsWriteable := cfg.CheckWriteable(hostname, "oauth_token") == nil
@@ -139,6 +141,12 @@ func statusRun(opts *StatusOptions) error {
139141
// not to since I wanted this command to be read-only.
140142
}
141143

144+
if !isHostnameFound {
145+
fmt.Fprintf(stderr,
146+
"You are not logged into any GitHub hosts. Run %s to authenticate.\n", cs.Bold(fmt.Sprintf("gh auth login -h %s", opts.Hostname)))
147+
return cmdutil.SilentError
148+
}
149+
142150
for _, hostname := range hostnames {
143151
lines, ok := statusInfo[hostname]
144152
if !ok {

0 commit comments

Comments
 (0)