go-mastodon/cmd/mstdn/cmd_delete.go
Yasuhiro Matsumoto 1a101faaae add delete command
2017-04-20 02:04:20 +09:00

29 lines
512 B
Go

package main
import (
"context"
"errors"
"strconv"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdDelete(c *cli.Context) error {
client := c.App.Metadata["client"].(*mastodon.Client)
if !c.Args().Present() {
return errors.New("arguments required")
}
for i := 0; i < c.NArg(); i++ {
id, err := strconv.ParseInt(c.Args().Get(i), 10, 64)
if err != nil {
return err
}
err = client.DeleteStatus(context.Background(), id)
if err != nil {
return err
}
}
return nil
}