]> Vexing Labs - dead-tooter.git/commitdiff
Move account load to PreRun
authorAdam Shamblin <adam@vexingworkshop.com>
Sun, 18 Dec 2022 05:34:33 +0000 (22:34 -0700)
committerAdam Shamblin <adam@vexingworkshop.com>
Sun, 18 Dec 2022 05:34:33 +0000 (22:34 -0700)
cmd/account.go

index c7a4f96ee32a03b58329302059e9e87ddbb099ab..93eed4d3428fb1518214ac0f534a38b0f13c1bc1 100644 (file)
@@ -7,6 +7,8 @@ import (
        "github.com/spf13/cobra"
 )
 
+var account mastodon.Account
+
 func init() {
        accountCmd.AddCommand(getFollowersCmd)
        rootCmd.AddCommand(accountCmd)
@@ -24,19 +26,21 @@ 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
+
+       PreRun: func(cmd *cobra.Command, args []string) {
                err := account.VerifyCredentials(host, token)
                if err != nil {
                        panic(err.Error())
                }
+       },
 
+       Run: func(cmd *cobra.Command, args []string) {
                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)
+                       fmt.Printf("%s\t%s\n", value.ID, value.Acct)
                }
        },
 }