go-mastodon/cmd/mstdn/cmd_toot.go

32 lines
522 B
Go
Raw Normal View History

2017-04-15 14:52:11 +02:00
package main
import (
"errors"
"log"
"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 {
log.Fatal(err)
}
toot = string(text)
} else {
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)
_, err := client.PostStatus(&mastodon.Toot{
Status: toot,
})
return err
}