Make account ID optional for accounts followers|following|statuses
authorMikael Berthe <mikael@lilotux.net>
Sat, 29 Apr 2017 13:54:04 +0200
changeset 28 79aa812c0dd2
parent 27 f4af03fd34a5
child 29 4f12e5d4ef75
Make account ID optional for accounts followers|following|statuses If the ID is missing, the account ID of the connected user is looked up.
cmd/accounts.go
--- a/cmd/accounts.go	Sat Apr 29 13:28:05 2017 +0200
+++ b/cmd/accounts.go	Sat Apr 29 13:54:04 2017 +0200
@@ -320,6 +320,19 @@
 		if opt.accountID < 1 || len(opt.statusIDs) == 0 || opt.comment == "" {
 			return errors.New("missing parameter")
 		}
+	case "followers", "following", "statuses":
+		// If the user's account ID is missing, get it
+		if opt.accountID < 1 {
+			// Sign in now to look the user id up
+			if err := madonInit(true); err != nil {
+				return err
+			}
+			account, err := gClient.GetCurrentAccount()
+			if err != nil {
+				return err
+			}
+			opt.accountID = account.ID
+		}
 	default:
 		// The other subcommands here require an account ID
 		if opt.accountID < 1 {