From: Adam Shamblin Date: Sun, 18 Dec 2022 05:34:33 +0000 (-0700) Subject: Move account load to PreRun X-Git-Url: https://git.vexinglabs.com/?a=commitdiff_plain;h=3f9f481fe9f22fc4be60b9bd0f580bd597e3668e;p=dead-tooter.git Move account load to PreRun --- diff --git a/cmd/account.go b/cmd/account.go index c7a4f96..93eed4d 100644 --- a/cmd/account.go +++ b/cmd/account.go @@ -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) } }, }