]> Vexing Labs - dead-tooter.git/commitdiff
successfully retreives and lists followers
authorAdam Shamblin <adam@vexingworkshop.com>
Sun, 18 Dec 2022 05:25:06 +0000 (22:25 -0700)
committerAdam Shamblin <adam@vexingworkshop.com>
Sun, 18 Dec 2022 05:25:06 +0000 (22:25 -0700)
cmd/account.go [new file with mode: 0644]
cmd/login.go
cmd/root.go

diff --git a/cmd/account.go b/cmd/account.go
new file mode 100644 (file)
index 0000000..c7a4f96
--- /dev/null
@@ -0,0 +1,42 @@
+package tooter
+
+import (
+       "fmt"
+
+       "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
+       "github.com/spf13/cobra"
+)
+
+func init() {
+       accountCmd.AddCommand(getFollowersCmd)
+       rootCmd.AddCommand(accountCmd)
+}
+
+var accountCmd = &cobra.Command{
+       Use:   "account",
+       Short: "Account commands",
+       Long:  "Commands related to the logged in Mastodon account.",
+       Run: func(cmd *cobra.Command, args []string) {
+       },
+}
+
+var getFollowersCmd = &cobra.Command{
+       Use:   "followers",
+       Short: "Get account followers",
+       Long:  "Get a list of followers for the current account.",
+       Run: func(cmd *cobra.Command, args []string) {
+               var account mastodon.Account
+               err := account.VerifyCredentials(host, token)
+               if err != nil {
+                       panic(err.Error())
+               }
+
+               followers, err := account.GetFollowers(host, token)
+               if err != nil {
+                       panic(err.Error())
+               }
+               for _, value := range followers {
+                       fmt.Printf("%s\t%s\n", value.ID, value.UserName)
+               }
+       },
+}
index 18427645304d1123786dc465a3e45de55234ef01..a2767253094d9571eca01e3c65cfc9629b5baaf4 100644 (file)
@@ -5,13 +5,7 @@ import (
        "github.com/spf13/cobra"
 )
 
-var host string
-
 func init() {
-       loginCmd.Flags().StringVarP(&host,
-               "host", "H", "", "Mastodon host where your account lives.")
-       loginCmd.MarkFlagRequired("host")
-
        rootCmd.AddCommand(loginCmd)
 }
 
index bb129bfec0d6d8516cee300dafe793278127e15a..f7b91f8b9c439b8ea5378857354324274e28bd18 100644 (file)
@@ -8,8 +8,15 @@ import (
        "github.com/spf13/cobra"
 )
 
+var host string
 var token mastodon.Token
 
+func init() {
+       rootCmd.PersistentFlags().StringVarP(&host,
+               "host", "H", "", "Mastodon host where your account lives.")
+       rootCmd.MarkFlagRequired("host")
+}
+
 var rootCmd = &cobra.Command{
        Use:   "dead-tooter",
        Short: "A CLI for Mastodon hate scripts",
@@ -36,6 +43,7 @@ var rootCmd = &cobra.Command{
        },
 }
 
+// Execute base command.
 func Execute() {
        if err := rootCmd.Execute(); err != nil {
                fmt.Println(err)