"github.com/spf13/cobra"
)
+var accountID string
var account mastodon.Account
func init() {
+ accountCmd.PersistentFlags().StringVarP(&accountID, "id", "", "", "ID of the Mastodon account")
+
accountCmd.AddCommand(getAccountCmd)
accountCmd.AddCommand(getFollowersCmd)
accountCmd.AddCommand(getFollowingCmd)
var getAccountCmd = &cobra.Command{
Use: "get [id]",
Short: "Get account info",
- Long: "Return information the account specified by [id]. If no id is supplied, return information on the current logged in user.",
+ Long: `Return information the account specified by [id]. If no id is supplied,
+return information on the current logged in user.`,
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(host, token)
},
Run: func(cmd *cobra.Command, args []string) {
- var id string
-
- if len(args) < 1 {
- id = account.ID
- } else {
- id = args[0]
+ if accountID == "" {
+ accountID = account.ID
}
- acct, err := mastodon.GetAccount(id, host, token)
+ acct, err := mastodon.GetAccount(accountID, host, token)
if err != nil {
fmt.Println("Failed to get account.")
os.Exit(1)