Reorganize the project layout, fix some logging quirks

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2025-12-30 19:13:42 -03:00
parent a2a93adfb6
commit 613576f438
11 changed files with 44 additions and 41 deletions

48
post.go Normal file
View File

@@ -0,0 +1,48 @@
package main
import (
"git.laidback.moe/shinyoukai/mikuru/mirai"
"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(mirai.Config.Host),
client.WithToken(mirai.Config.Token),
)
if err != nil {
log.Fatalf("Unable to create client\n%s\n", err)
}
write(cli)
},
}
func init() {
rootCmd.AddCommand(postCmd)
mirai.ConfInit()
}
func write(cli *client.Client) {
var post string
data, err := editor.Read()
if err != nil {
log.Fatalf("Unable to read content from editor\n%s\n", err)
}
post = string(data)
_, err = cli.Post(post, "")
if err != nil {
log.Fatalf("Unable to publish tweet\n%s\n", err)
}
}