package tooter
import (
+ "errors"
"fmt"
"git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
)
func init() {
+ listCmd.AddCommand(listAccountsCmd)
listCmd.AddCommand(listsContainingCmd)
rootCmd.AddCommand(listCmd)
Long: "Commands related to account lists.",
}
+var listAccountsCmd = &cobra.Command{
+ Use: "accounts",
+ Short: "Get list accounts",
+ Long: "Get accounts in a list",
+
+ Args: func(cmd *cobra.Command, args []string) error {
+ if len(args) < 1 {
+ return errors.New("Must provide list id")
+ }
+ return nil
+ },
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(host, token)
+ if err != nil {
+ fmt.Printf("Unable to verify credentials: %s\n", err.Error())
+ return
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ list, err := mastodon.GetList(args[0], host, token)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ accounts, err := list.GetAccounts(host, token)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ fmt.Printf("%+v", accounts)
+ },
+}
+
var listsContainingCmd = &cobra.Command{
Use: "containing",
Short: "Get lists containing [accountid]",