理由はありません

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2026-01-22 16:46:37 -03:00
parent 618908f54b
commit 8f24b2f36b
5 changed files with 16 additions and 13 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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