package main import ( "log" "code.laidback.moe/go-writefreely" "github.com/spf13/cobra" ) var logoutCmd = &cobra.Command{ Use: "logout", Short: "Log out from WriteFreely, invalidating the token", Run: func(_ *cobra.Command, args []string) { Logout(args) }, } func init() { ConfInit() rootCmd.AddCommand(logoutCmd) } // Un-authenticates a user with WriteFreely, permanently // invalidating the access token used with the request. func Logout(args []string) { c := writefreely.NewClient(Config.Host) c.SetToken(Config.Token) err := c.Logout() if err != nil { log.Fatal(err) } log.Println("Logged out") log.Println("Remove the token from the configuration file") }