go-mastodon/cmd/mstdn/cmd_followers.go

29 lines
623 B
Go
Raw Normal View History

2017-04-16 15:27:54 +02:00
package main
import (
"context"
2017-04-16 15:27:54 +02:00
"fmt"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdFollowers(c *cli.Context) error {
client := c.App.Metadata["client"].(*mastodon.Client)
2017-04-19 16:32:23 +02:00
config := c.App.Metadata["config"].(*mastodon.Config)
account, err := client.GetAccountCurrentUser(context.Background())
2017-04-16 15:27:54 +02:00
if err != nil {
return err
}
followers, err := client.GetAccountFollowers(context.Background(), account.ID)
2017-04-16 15:27:54 +02:00
if err != nil {
return err
}
2017-04-19 16:32:23 +02:00
s := newScreen(config)
2017-04-16 15:27:54 +02:00
for _, follower := range followers {
2017-04-19 16:32:23 +02:00
fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, s.acct(follower.Acct))
2017-04-16 15:27:54 +02:00
}
return nil
}