2017-04-15 14:52:11 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-17 04:10:29 +02:00
|
|
|
"context"
|
2017-04-15 14:52:11 +02:00
|
|
|
"errors"
|
2017-10-25 03:22:39 +02:00
|
|
|
"fmt"
|
2017-04-15 14:52:11 +02:00
|
|
|
|
|
|
|
"github.com/mattn/go-mastodon"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func cmdToot(c *cli.Context) error {
|
|
|
|
var toot string
|
|
|
|
ff := c.String("ff")
|
|
|
|
if ff != "" {
|
|
|
|
text, err := readFile(ff)
|
|
|
|
if err != nil {
|
2017-04-24 12:40:20 +02:00
|
|
|
return err
|
2017-04-15 14:52:11 +02:00
|
|
|
}
|
|
|
|
toot = string(text)
|
|
|
|
} else {
|
2017-04-16 03:41:21 +02:00
|
|
|
if !c.Args().Present() {
|
|
|
|
return errors.New("arguments required")
|
|
|
|
}
|
2017-04-15 16:21:45 +02:00
|
|
|
toot = argstr(c)
|
2017-04-15 14:52:11 +02:00
|
|
|
}
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
2017-04-17 04:10:29 +02:00
|
|
|
_, err := client.PostStatus(context.Background(), &mastodon.Toot{
|
2017-04-19 08:17:26 +02:00
|
|
|
Status: toot,
|
2017-10-25 03:22:39 +02:00
|
|
|
InReplyToID: mastodon.ID(fmt.Sprint(c.Int64("i"))),
|
2017-04-15 14:52:11 +02:00
|
|
|
})
|
|
|
|
return err
|
|
|
|
}
|