Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 60688d7a0e | |||
| 811028bebc | |||
| 57a2914fe3 | |||
| cf64d9038f |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/mikuru-*
|
||||||
18
Makefile
18
Makefile
@@ -1,13 +1,13 @@
|
|||||||
|
VERSION = `git describe --tags` || echo MIRAI
|
||||||
|
|
||||||
GO = go
|
GO = go
|
||||||
GOFLAGS = -v -ldflags "-w -X mikuru.Version=${VERSION} -X mikuru.Rev=${REVISION}"
|
GOFLAGS = -v -buildvcs=false -buildmode=exe -ldflags "-w -X `${GO} list`.Version=${VERSION}"
|
||||||
REVISION = `git rev-list --all | wc -l`
|
|
||||||
VERSION = HEAD
|
|
||||||
|
|
||||||
PROGRAMS = mikuru-login \
|
build: mikuru-login mikuru-post
|
||||||
mikuru-post \
|
|
||||||
mikuru-timeline
|
|
||||||
|
|
||||||
build:
|
mikuru-login:
|
||||||
${GO} build ${GOFLAGS} ./cmd/${PROGRAMS}
|
${GO} build ${GOFLAGS} ./cmd/$@
|
||||||
|
mikuru-post:
|
||||||
|
${GO} build ${GOFLAGS} ./cmd/$@
|
||||||
clean:
|
clean:
|
||||||
rm -f ${PROGRAMS}
|
rm -f mikuru-*
|
||||||
|
|||||||
@@ -2,15 +2,16 @@
|
|||||||
[Yarn.social](https://yarn.social) client where each task (except for logout) is handled by a separate program.
|
[Yarn.social](https://yarn.social) client where each task (except for logout) is handled by a separate program.
|
||||||
|
|
||||||
## Current status
|
## Current status
|
||||||
|
* [ ] Follow/Unfollow
|
||||||
* [X] Login
|
* [X] Login
|
||||||
* [ ] Posting
|
* [X] Posting
|
||||||
* [ ] Timeline
|
* [ ] Timeline
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[ISC](COPYING)
|
[ISC](COPYING)
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
* [Go](https://go.dev) (>=1.20)
|
* [Go](https://go.dev) (>=1.24)
|
||||||
|
|
||||||
## Where did the name come from?
|
## Where did the name come from?
|
||||||
Huh? I couldn't possibly tell you about that!
|
Huh? I couldn't possibly tell you about that!
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
@@ -16,24 +18,22 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
xdg_config_home, err := os.UserConfigDir()
|
mikuru.ConfInit()
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Unable to obtain user's configuration directory")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
configPath := xdg_config_home + "/mikuru.ini"
|
|
||||||
mikuru.Parse(configPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cli, err := client.NewClient(client.WithURI(mikuru.Config.Host))
|
cli, err := client.NewClient(client.WithURI(mikuru.Config.Host))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s", err)
|
log.Println("Unable to create client")
|
||||||
fmt.Println("Error creating client")
|
log.Fatal(err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("Welcome to Mikuru!")
|
||||||
|
fmt.Printf("%s\n", mikuru.PrintVersion())
|
||||||
|
|
||||||
signin(cli)
|
signin(cli)
|
||||||
}
|
}
|
||||||
|
|
||||||
func signin(cli *client.Client) {
|
func signin(cli *client.Client) {
|
||||||
fmt.Printf("Username: ")
|
fmt.Printf("Username: ")
|
||||||
fmt.Scanln(&username)
|
fmt.Scanln(&username)
|
||||||
@@ -59,9 +59,11 @@ func signin(cli *client.Client) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
token := strings.Trim(fmt.Sprintf(res.Token), "{}")
|
||||||
|
|
||||||
|
|
||||||
fmt.Println("Login successful")
|
fmt.Println("Login successful")
|
||||||
fmt.Println("Place this token in your configuration file for later use")
|
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("Do not share it with anyone, it's classified information")
|
||||||
fmt.Println("Trim surrounding braces before usage")
|
fmt.Printf("token = %v\n", token)
|
||||||
fmt.Printf("token = %v\n", res)
|
|
||||||
}
|
}
|
||||||
|
|||||||
43
cmd/mikuru-post/main.go
Normal file
43
cmd/mikuru-post/main.go
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
12
config.go
12
config.go
@@ -1,6 +1,8 @@
|
|||||||
package mikuru
|
package mikuru
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
"gopkg.in/ini.v1"
|
"gopkg.in/ini.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,6 +11,16 @@ var Config struct {
|
|||||||
Token string
|
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 {
|
func Parse(file string) error {
|
||||||
cfg, err := ini.Load(file)
|
cfg, err := ini.Load(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -1,14 +1,16 @@
|
|||||||
module git.laidback.moe/shinyoukai/mikuru
|
module git.laidback.moe/shinyoukai/mikuru
|
||||||
|
|
||||||
go 1.20
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/tj/go-editor v1.0.0
|
||||||
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e
|
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e
|
||||||
golang.org/x/term v0.38.0
|
golang.org/x/term v0.38.0
|
||||||
gopkg.in/ini.v1 v1.67.0
|
gopkg.in/ini.v1 v1.67.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/pkg/errors v0.8.1 // indirect
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
github.com/stretchr/testify v1.11.1 // indirect
|
github.com/stretchr/testify v1.11.1 // indirect
|
||||||
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 // indirect
|
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -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/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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
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.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 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
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 h1:A4wok2/cSAbvWLjHhtCrW8dvv1XlgcGRj7H15150HhA=
|
||||||
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg=
|
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg=
|
||||||
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE=
|
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE=
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Revision = "0"
|
|
||||||
Version = "0"
|
Version = "0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrintVersion() string {
|
func PrintVersion() string {
|
||||||
return fmt.Sprintf("%s (%s)", Version, Revision)
|
return fmt.Sprintf("%s", Version)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user