4 Commits

Author SHA1 Message Date
60688d7a0e Do not repeat code whenever possible
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 07:53:26 -03:00
811028bebc Update roadmap
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 00:39:20 -03:00
57a2914fe3 Fix token retrieval
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 00:37:25 -03:00
cf64d9038f Sending messages to the Æther
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 00:13:59 -03:00
9 changed files with 90 additions and 26 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/mikuru-*

View File

@@ -1,13 +1,13 @@
VERSION = `git describe --tags` || echo MIRAI
GO = go
GOFLAGS = -v -ldflags "-w -X mikuru.Version=${VERSION} -X mikuru.Rev=${REVISION}"
REVISION = `git rev-list --all | wc -l`
VERSION = HEAD
GOFLAGS = -v -buildvcs=false -buildmode=exe -ldflags "-w -X `${GO} list`.Version=${VERSION}"
PROGRAMS = mikuru-login \
mikuru-post \
mikuru-timeline
build: mikuru-login mikuru-post
build:
${GO} build ${GOFLAGS} ./cmd/${PROGRAMS}
mikuru-login:
${GO} build ${GOFLAGS} ./cmd/$@
mikuru-post:
${GO} build ${GOFLAGS} ./cmd/$@
clean:
rm -f ${PROGRAMS}
rm -f mikuru-*

View File

@@ -2,15 +2,16 @@
[Yarn.social](https://yarn.social) client where each task (except for logout) is handled by a separate program.
## Current status
* [ ] Follow/Unfollow
* [X] Login
* [ ] Posting
* [X] Posting
* [ ] Timeline
## License
[ISC](COPYING)
## Requirements
* [Go](https://go.dev) (>=1.20)
* [Go](https://go.dev) (>=1.24)
## Where did the name come from?
Huh? I couldn't possibly tell you about that!

View File

@@ -2,7 +2,9 @@ package main
import (
"fmt"
"log"
"os"
"strings"
"syscall"
"golang.org/x/term"
@@ -16,24 +18,22 @@ var (
)
func init() {
xdg_config_home, err := os.UserConfigDir()
if err != nil {
fmt.Println("Unable to obtain user's configuration directory")
os.Exit(1)
}
configPath := xdg_config_home + "/mikuru.ini"
mikuru.Parse(configPath)
mikuru.ConfInit()
}
func main() {
cli, err := client.NewClient(client.WithURI(mikuru.Config.Host))
if err != nil {
fmt.Printf("%s", err)
fmt.Println("Error creating client")
os.Exit(1)
log.Println("Unable to create client")
log.Fatal(err)
}
fmt.Println("Welcome to Mikuru!")
fmt.Printf("%s\n", mikuru.PrintVersion())
signin(cli)
}
func signin(cli *client.Client) {
fmt.Printf("Username: ")
fmt.Scanln(&username)
@@ -59,9 +59,11 @@ func signin(cli *client.Client) {
os.Exit(1)
}
token := strings.Trim(fmt.Sprintf(res.Token), "{}")
fmt.Println("Login successful")
fmt.Println("Place this token in your configuration file for later use")
fmt.Println("Do not share it with anyone, it's classified information")
fmt.Println("Trim surrounding braces before usage")
fmt.Printf("token = %v\n", res)
fmt.Printf("token = %v\n", token)
}

43
cmd/mikuru-post/main.go Normal file
View File

@@ -0,0 +1,43 @@
package main
import (
"log"
"git.laidback.moe/shinyoukai/mikuru"
"go.yarn.social/client"
"github.com/tj/go-editor"
)
func init() {
mikuru.ConfInit()
}
func main() {
cli, err := client.NewClient(
client.WithURI(mikuru.Config.Host),
client.WithToken(mikuru.Config.Token),
)
if err != nil {
log.Fatal(err)
}
write(cli)
}
func write(cli *client.Client) {
var post string
data, err := editor.Read()
if err != nil {
log.Fatal("Unable to read content from editor")
}
post = string(data)
_, err = cli.Post(post, "")
if err != nil {
log.Fatal("Unable to publish tweet")
}
}

View File

@@ -1,6 +1,8 @@
package mikuru
import (
"log"
"os"
"gopkg.in/ini.v1"
)
@@ -9,6 +11,16 @@ var Config struct {
Token string
}
func ConfInit() {
config, err := os.UserConfigDir()
if err != nil {
log.Println("Unable to obtain user's configuration directory")
log.Fatal(err)
}
configPath := config + "/mikuru.ini"
Parse(configPath)
}
func Parse(file string) error {
cfg, err := ini.Load(file)
if err != nil {

4
go.mod
View File

@@ -1,14 +1,16 @@
module git.laidback.moe/shinyoukai/mikuru
go 1.20
go 1.24.0
require (
github.com/tj/go-editor v1.0.0
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e
golang.org/x/term v0.38.0
gopkg.in/ini.v1 v1.67.0
)
require (
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.11.1 // indirect
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 // indirect

4
go.sum
View File

@@ -5,6 +5,8 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
@@ -15,6 +17,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tj/go-editor v1.0.0 h1:VduwRZWk5gxHbzRkS4buB9BIFzAf6Jc+vd2bLZpHzSw=
github.com/tj/go-editor v1.0.0/go.mod h1:Jj9Ze2Rn2yj5DmMppydZqr9LbkIcCWrehzZ+7udOT+w=
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e h1:A4wok2/cSAbvWLjHhtCrW8dvv1XlgcGRj7H15150HhA=
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg=
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE=

View File

@@ -5,10 +5,9 @@ import (
)
var (
Revision = "0"
Version = "0"
)
func PrintVersion() string {
return fmt.Sprintf("%s (%s)", Version, Revision)
return fmt.Sprintf("%s", Version)
}