add delete command
This commit is contained in:
parent
293a9e0aba
commit
1a101faaae
4 changed files with 76 additions and 0 deletions
28
cmd/mstdn/cmd_delete.go
Normal file
28
cmd/mstdn/cmd_delete.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue