20 var accountUpdateFlags, accountMuteFlags, accountFollowFlags *flag.FlagSet |
20 var accountUpdateFlags, accountMuteFlags, accountFollowFlags *flag.FlagSet |
21 |
21 |
22 var accountsOpts struct { |
22 var accountsOpts struct { |
23 accountID madon.ActivityID |
23 accountID madon.ActivityID |
24 accountUID string |
24 accountUID string |
25 unset bool // TODO remove eventually? |
|
26 limit, keep uint // Limit the results |
25 limit, keep uint // Limit the results |
27 sinceID, maxID madon.ActivityID // Query boundaries |
26 sinceID, maxID madon.ActivityID // Query boundaries |
28 all bool // Try to fetch all results |
27 all bool // Try to fetch all results |
29 onlyMedia, onlyPinned bool // For acccount statuses |
28 onlyMedia, onlyPinned bool // For acccount statuses |
30 excludeReplies bool // For acccount statuses |
29 excludeReplies bool // For acccount statuses |
68 |
67 |
69 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.list, "list", false, "List pending follow requests") |
68 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.list, "list", false, "List pending follow requests") |
70 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.acceptFR, "accept", false, "Accept the follow request from the account ID") |
69 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.acceptFR, "accept", false, "Accept the follow request from the account ID") |
71 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.rejectFR, "reject", false, "Reject the follow request from the account ID") |
70 accountFollowRequestsSubcommand.Flags().BoolVar(&accountsOpts.rejectFR, "reject", false, "Reject the follow request from the account ID") |
72 |
71 |
73 accountBlockSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unblock the account (deprecated)") |
|
74 |
|
75 accountMuteSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unmute the account (deprecated)") |
|
76 accountMuteSubcommand.Flags().BoolVarP(&accountsOpts.muteNotifications, "notifications", "", true, "Mute the notifications") |
72 accountMuteSubcommand.Flags().BoolVarP(&accountsOpts.muteNotifications, "notifications", "", true, "Mute the notifications") |
77 accountFollowSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unfollow the account (deprecated)") |
|
78 accountFollowSubcommand.Flags().BoolVarP(&accountsOpts.reblogs, "show-reblogs", "", true, "Follow account's boosts") |
73 accountFollowSubcommand.Flags().BoolVarP(&accountsOpts.reblogs, "show-reblogs", "", true, "Follow account's boosts") |
79 accountFollowSubcommand.Flags().StringVarP(&accountsOpts.remoteUID, "remote", "r", "", "Follow remote account (user@domain)") |
74 accountFollowSubcommand.Flags().StringVarP(&accountsOpts.remoteUID, "remote", "r", "", "Follow remote account (user@domain)") |
80 |
75 |
81 accountRelationshipsSubcommand.Flags().StringVar(&accountsOpts.accountIDs, "account-ids", "", "Comma-separated list of account IDs") |
76 accountRelationshipsSubcommand.Flags().StringVar(&accountsOpts.accountIDs, "account-ids", "", "Comma-separated list of account IDs") |
82 |
77 |
94 accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultLanguage, "default-language", "", "Default toots language (iso 639 code)") |
89 accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultLanguage, "default-language", "", "Default toots language (iso 639 code)") |
95 accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultPrivacy, "default-privacy", "", "Default toot privacy (public, unlisted, private)") |
90 accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultPrivacy, "default-privacy", "", "Default toot privacy (public, unlisted, private)") |
96 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.defaultSensitive, "default-sensitive", false, "Mark medias as sensitive by default") |
91 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.defaultSensitive, "default-sensitive", false, "Mark medias as sensitive by default") |
97 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval") |
92 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval") |
98 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account") |
93 accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account") |
99 |
|
100 // Deprecated flags |
|
101 accountBlockSubcommand.Flags().MarkDeprecated("unset", "please use unblock instead") |
|
102 accountMuteSubcommand.Flags().MarkDeprecated("unset", "please use unmute instead") |
|
103 accountFollowSubcommand.Flags().MarkDeprecated("unset", "please use unfollow instead") |
|
104 |
94 |
105 // Those variables will be used to check if the options were |
95 // Those variables will be used to check if the options were |
106 // explicitly set or not |
96 // explicitly set or not |
107 accountUpdateFlags = accountUpdateSubcommand.Flags() |
97 accountUpdateFlags = accountUpdateSubcommand.Flags() |
108 accountMuteFlags = accountMuteSubcommand.Flags() |
98 accountMuteFlags = accountMuteSubcommand.Flags() |
450 return errors.New("missing account ID or URI") |
440 return errors.New("missing account ID or URI") |
451 } |
441 } |
452 if opt.accountID != "" && opt.remoteUID != "" { |
442 if opt.accountID != "" && opt.remoteUID != "" { |
453 return errors.New("cannot use both account ID and URI") |
443 return errors.New("cannot use both account ID and URI") |
454 } |
444 } |
455 if (opt.unset || subcmd == "unfollow") && opt.accountID == "" { |
445 if subcmd == "unfollow" && opt.accountID == "" { |
456 return errors.New("unfollowing requires an account ID") |
446 return errors.New("unfollowing requires an account ID") |
457 } |
447 } |
458 case "follow-requests": |
448 case "follow-requests": |
459 if opt.list { |
449 if opt.list { |
460 if opt.acceptFR || opt.rejectFR { |
450 if opt.acceptFR || opt.rejectFR { |
567 statusList = statusList[:opt.keep] |
557 statusList = statusList[:opt.keep] |
568 } |
558 } |
569 obj = statusList |
559 obj = statusList |
570 case "follow", "unfollow": |
560 case "follow", "unfollow": |
571 var relationship *madon.Relationship |
561 var relationship *madon.Relationship |
572 if opt.unset || subcmd == "unfollow" { |
562 if subcmd == "unfollow" { |
573 relationship, err = gClient.UnfollowAccount(opt.accountID) |
563 relationship, err = gClient.UnfollowAccount(opt.accountID) |
574 obj = relationship |
564 obj = relationship |
575 break |
565 break |
576 } |
566 } |
577 if opt.accountID == "" { |
567 if opt.accountID == "" { |
619 } else { |
609 } else { |
620 err = gClient.FollowRequestAuthorize(opt.accountID, !opt.rejectFR) |
610 err = gClient.FollowRequestAuthorize(opt.accountID, !opt.rejectFR) |
621 } |
611 } |
622 case "block", "unblock": |
612 case "block", "unblock": |
623 var relationship *madon.Relationship |
613 var relationship *madon.Relationship |
624 if opt.unset || subcmd == "unblock" { |
614 if subcmd == "unblock" { |
625 relationship, err = gClient.UnblockAccount(opt.accountID) |
615 relationship, err = gClient.UnblockAccount(opt.accountID) |
626 } else { |
616 } else { |
627 relationship, err = gClient.BlockAccount(opt.accountID) |
617 relationship, err = gClient.BlockAccount(opt.accountID) |
628 } |
618 } |
629 obj = relationship |
619 obj = relationship |
630 case "mute", "unmute": |
620 case "mute", "unmute": |
631 var relationship *madon.Relationship |
621 var relationship *madon.Relationship |
632 if opt.unset || subcmd == "unmute" { |
622 if subcmd == "unmute" { |
633 relationship, err = gClient.UnmuteAccount(opt.accountID) |
623 relationship, err = gClient.UnmuteAccount(opt.accountID) |
634 } else { |
624 } else { |
635 var muteNotif *bool |
625 var muteNotif *bool |
636 if accountMuteFlags.Lookup("notifications").Changed { |
626 if accountMuteFlags.Lookup("notifications").Changed { |
637 muteNotif = &opt.muteNotifications |
627 muteNotif = &opt.muteNotifications |