func errorQuit(err error) { if errgo.Cause(err) == api.LoginAbortedErr { fmt.Printf("... %v\n", err) os.Exit(1) } if api.IsRequestFailedError(errgo.Cause(err)) { code := errgo.Cause(err).(*api.RequestFailedError).Code if code == 401 { session.DestroyToken() } } newReportError(err).Report() rollbar.Wait() io.Error("An error occured:") fmt.Println(io.Indent(err.Error(), 7)) os.Exit(1) }
package cmd import ( "fmt" "github.com/Scalingo/cli/Godeps/_workspace/src/github.com/Scalingo/codegangsta-cli" "github.com/Scalingo/cli/cmd/autocomplete" "github.com/Scalingo/cli/session" ) var ( LogoutCommand = cli.Command{ Name: "logout", Category: "Global", Usage: "Logout from Scalingo", Description: "Destroy login information stored on your computer", Action: func(c *cli.Context) { if err := session.DestroyToken(); err != nil { panic(err) } fmt.Println("Scalingo credentials have been deleted.") }, BashComplete: func(c *cli.Context) { autocomplete.CmdFlagsAutoComplete(c, "logout") }, } )