Files
yuki/logout.go
2026-01-22 16:46:37 -03:00

37 lines
690 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) {
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")
}