separate command
This commit is contained in:
parent
094a888b1d
commit
209a15a4d7
4 changed files with 100 additions and 76 deletions
33
cmd/mstdn/cmd_toot.go
Normal file
33
cmd/mstdn/cmd_toot.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-mastodon"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func cmdToot(c *cli.Context) error {
|
||||
if !c.Args().Present() {
|
||||
return errors.New("arguments required")
|
||||
}
|
||||
|
||||
var toot string
|
||||
ff := c.String("ff")
|
||||
if ff != "" {
|
||||
text, err := readFile(ff)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
toot = string(text)
|
||||
} else {
|
||||
toot = strings.Join(c.Args().Tail(), " ")
|
||||
}
|
||||
client := c.App.Metadata["client"].(*mastodon.Client)
|
||||
_, err := client.PostStatus(&mastodon.Toot{
|
||||
Status: toot,
|
||||
})
|
||||
return err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue