Fix detecting cases when cfg.Hosts() is empty
This commit is contained in:
parent
aec0f10041
commit
c598a1edc2
3 changed files with 10 additions and 1 deletions
|
|
@ -74,6 +74,9 @@ func logoutRun(opts *LogoutOptions) error {
|
|||
|
||||
candidates, err := cfg.Hosts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(candidates) == 0 {
|
||||
return fmt.Errorf("not logged in to any hosts")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ func refreshRun(opts *RefreshOptions) error {
|
|||
|
||||
candidates, err := cfg.Hosts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(candidates) == 0 {
|
||||
return fmt.Errorf("not logged in to any hosts. Use 'gh auth login' to authenticate with a host")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,10 @@ func statusRun(opts *StatusOptions) error {
|
|||
statusInfo := map[string][]string{}
|
||||
|
||||
hostnames, err := cfg.Hosts()
|
||||
if len(hostnames) == 0 || err != nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(hostnames) == 0 {
|
||||
fmt.Fprintf(stderr,
|
||||
"You are not logged into any GitHub hosts. Run %s to authenticate.\n", cs.Bold("gh auth login"))
|
||||
return cmdutil.SilentError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue