From 8f24b2f36be96124e25b2fb76dcff138dc7173a0 Mon Sep 17 00:00:00 2001 From: Shin'ya Minazuki Date: Thu, 22 Jan 2026 16:46:37 -0300 Subject: [PATCH] =?UTF-8?q?=E7=90=86=E7=94=B1=E3=81=AF=E3=81=82=E3=82=8A?= =?UTF-8?q?=E3=81=BE=E3=81=9B=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shin'ya Minazuki --- delete.go | 5 +++-- login.go | 8 +++----- logout.go | 6 ++++-- post.go | 5 +++-- update.go | 5 +++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/delete.go b/delete.go index e312f3d..9274b7d 100644 --- a/delete.go +++ b/delete.go @@ -16,7 +16,7 @@ var deleteCmd = &cobra.Command{ if err != nil { log.Fatal("Unable to get id flag") } - DoDelete(id, args) + Delete(id, args) }, } @@ -27,7 +27,8 @@ func init() { if err := deleteCmd.MarkFlagRequired("id"); err != nil { panic(err) } } -func DoDelete(id string, args []string) { +// Delete permanently a post from WriteFreely. +func Delete(id string, args []string) { c := writefreely.NewClient(Config.Host) c.SetToken(Config.Token) diff --git a/login.go b/login.go index 30edcf5..ba7c001 100644 --- a/login.go +++ b/login.go @@ -16,7 +16,7 @@ var loginCmd = &cobra.Command{ Use: "login", Short: "Login to a WriteFreely instance", Run: func(cmd *cobra.Command, args []string) { - DoLogin(args) + Login(args) }, } @@ -25,10 +25,8 @@ func init() { rootCmd.AddCommand(loginCmd) } -// DoLogin creates a new client, passing the host defined -// in the configuration file as writefreely.InstanceURL, -// and authenticates to the instance. -func DoLogin(args []string) { +// Authenticates a user with WriteFreely +func Login(args []string) { var user, pass string c := writefreely.NewClient(Config.Host) diff --git a/logout.go b/logout.go index 0f526b8..28ddeae 100644 --- a/logout.go +++ b/logout.go @@ -11,7 +11,7 @@ var logoutCmd = &cobra.Command{ Use: "logout", Short: "Log out from WriteFreely, invalidating the token", Run: func(_ *cobra.Command, args []string) { - DoLogout(args) + Logout(args) }, } @@ -20,7 +20,9 @@ func init() { rootCmd.AddCommand(logoutCmd) } -func DoLogout(args []string) { +// 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) diff --git a/post.go b/post.go index 34c63f8..02b7039 100644 --- a/post.go +++ b/post.go @@ -34,7 +34,7 @@ var postCmd = &cobra.Command{ log.Fatal("Couldn't get the title flag") } - DoPost(collection, font, lang, rtl, title, args) + Post(collection, font, lang, rtl, title, args) }, } @@ -49,7 +49,8 @@ func init() { if err := postCmd.MarkFlagRequired("title"); err != nil { panic(err) } } -func DoPost(collection, font, lang string, rtl bool, title string, args []string) { +// Post allows an user to publish to a WriteFreely instance +func Post(collection, font, lang string, rtl bool, title string, args []string) { var err error var w *writefreely.Post diff --git a/update.go b/update.go index 2539d52..3926809 100644 --- a/update.go +++ b/update.go @@ -37,7 +37,7 @@ var updateCmd = &cobra.Command{ log.Fatal("Couldn't get the title flag") } - DoUpdate(id, collection, font, lang, rtl, title, args) + Update(id, collection, font, lang, rtl, title, args) }, } @@ -53,7 +53,8 @@ func init() { rootCmd.AddCommand(updateCmd) } -func DoUpdate(id, collection, font, lang string, rtl bool, title string, args []string) { +// Update an existing post (this can overwrite it) +func Update(id, collection, font, lang string, rtl bool, title string, args []string) { var err error var w *writefreely.Post