Files
yuki/logout.go
Shin'ya Minazuki 3def8e4eee Update go-writefreely to v1.4.0
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>
2026-01-22 12:26:57 -03:00

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")
}