Switch to Cobra

Also:
- Fixed the Makefile
- Added a Taskfile.yml (see: https://taskfile.dev)
- Updated the manual page

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2025-12-30 12:10:46 -03:00
parent 60688d7a0e
commit f045e36119
12 changed files with 168 additions and 84 deletions

48
cmd/post.go Normal file
View File

@@ -0,0 +1,48 @@
package main
import (
"git.laidback.moe/shinyoukai/mikuru"
"go.yarn.social/client"
"github.com/tj/go-editor"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var postCmd = &cobra.Command{
Use: "post",
Aliases: []string{"tweet"},
Short: "Publish a new post to a Yarn pod",
Run: func(_ *cobra.Command, args []string) {
cli, err := client.NewClient(
client.WithURI(mikuru.Config.Host),
client.WithToken(mikuru.Config.Token),
)
if err != nil {
log.Fatal("Unable to create client", err)
}
write(cli)
},
}
func init() {
rootCmd.AddCommand(postCmd)
mikuru.ConfInit()
}
func write(cli *client.Client) {
var post string
data, err := editor.Read()
if err != nil {
log.Fatal("Unable to read content from editor", err)
}
post = string(data)
_, err = cli.Post(post, "")
if err != nil {
log.Fatal("Unable to publish tweet", err)
}
}