Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions commands/auth/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package auth

import (
"fmt"
"os"

"github.com/pusher/cli/config"
"github.com/spf13/cobra"
"github.com/theherk/viper"
)

// Logout removes the users API key from the machine.
Expand All @@ -14,13 +13,11 @@ var Logout = &cobra.Command{
Short: "Remove Pusher account credentials from this computer",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {

deleteErr := config.Delete()
if deleteErr == nil {
fmt.Println("Removed Pusher account credentials.")
} else {
fmt.Println("Failed to remove the local configuration. Is it there?")
os.Exit(1)
viper.Set("token", "")
err := viper.WriteConfig()
if err != nil {
panic("Could not write config: " + err.Error())
}
fmt.Println("Removed Pusher account credentials.")
},
}
5 changes: 0 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,3 @@ func Init() {
panic(err)
}
}

// Delete deletes the config file.
func Delete() error {
return os.Remove(getConfigPath())
}