As it was a breaking change, all the code using it has been modified accordingly. That also means less lines of code for doing the same thing, too. Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
35 lines
581 B
Go
35 lines
581 B
Go
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) {
|
|
DoLogout(args)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
ConfInit()
|
|
rootCmd.AddCommand(logoutCmd)
|
|
}
|
|
|
|
func DoLogout(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")
|
|
}
|