cmd/accounts.go
changeset 224 d33a2c4fdfbf
parent 223 0412068a9445
child 226 5df927fa87ca
equal deleted inserted replaced
223:0412068a9445 224:d33a2c4fdfbf
    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             int64
    23 	accountID             int64
    24 	accountUID            string
    24 	accountUID            string
    25 	unset                 bool   // TODO remove eventually?
    25 	unset                 bool     // TODO remove eventually?
    26 	limit, keep           uint   // Limit the results
    26 	limit, keep           uint     // Limit the results
    27 	sinceID, maxID        int64  // Query boundaries
    27 	sinceID, maxID        int64    // Query boundaries
    28 	all                   bool   // Try to fetch all results
    28 	all                   bool     // Try to fetch all results
    29 	onlyMedia, onlyPinned bool   // For acccount statuses
    29 	onlyMedia, onlyPinned bool     // For acccount statuses
    30 	excludeReplies        bool   // For acccount statuses
    30 	excludeReplies        bool     // For acccount statuses
    31 	remoteUID             string // For account follow
    31 	remoteUID             string   // For account follow
    32 	reblogs               bool   // For account follow
    32 	reblogs               bool     // For account follow
    33 	acceptFR, rejectFR    bool   // For account follow_requests
    33 	acceptFR, rejectFR    bool     // For account follow_requests
    34 	list                  bool   // For account follow_requests/reports
    34 	list                  bool     // For account follow_requests/reports
    35 	accountIDs            string // For account relationships
    35 	accountIDs            string   // For account relationships
    36 	statusIDs             string // For account reports
    36 	statusIDs             string   // For account reports
    37 	comment               string // For account reports
    37 	comment               string   // For account reports
    38 	displayName, note     string // For account update
    38 	displayName, note     string   // For account update
    39 	avatar, header        string // For account update
    39 	profileFields         []string // For account update
    40 	defaultLanguage       string // For account update
    40 	avatar, header        string   // For account update
    41 	defaultPrivacy        string // For account update
    41 	defaultLanguage       string   // For account update
    42 	defaultSensitive      bool   // For account update
    42 	defaultPrivacy        string   // For account update
    43 	locked, bot           bool   // For account update
    43 	defaultSensitive      bool     // For account update
    44 	muteNotifications     bool   // For account mute
    44 	locked, bot           bool     // For account update
    45 	following             bool   // For account search
    45 	muteNotifications     bool     // For account mute
       
    46 	following             bool     // For account search
    46 }
    47 }
    47 
    48 
    48 func init() {
    49 func init() {
    49 	RootCmd.AddCommand(accountsCmd)
    50 	RootCmd.AddCommand(accountsCmd)
    50 
    51 
    87 
    88 
    88 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.displayName, "display-name", "", "User display name")
    89 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.displayName, "display-name", "", "User display name")
    89 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.note, "note", "", "User note (a.k.a. bio)")
    90 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.note, "note", "", "User note (a.k.a. bio)")
    90 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.avatar, "avatar", "", "User avatar image")
    91 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.avatar, "avatar", "", "User avatar image")
    91 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.header, "header", "", "User header image")
    92 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.header, "header", "", "User header image")
       
    93 	accountUpdateSubcommand.Flags().StringArrayVar(&accountsOpts.profileFields, "profile-field", nil, "Profile metadata field (NAME=VALUE)")
    92 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultLanguage, "default-language", "", "Default toots language (iso 639 code)")
    94 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultLanguage, "default-language", "", "Default toots language (iso 639 code)")
    93 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultPrivacy, "default-privacy", "", "Default toot privacy (public, unlisted, private)")
    95 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultPrivacy, "default-privacy", "", "Default toot privacy (public, unlisted, private)")
    94 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.defaultSensitive, "default-sensitive", false, "Mark medias as sensitive by default")
    96 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.defaultSensitive, "default-sensitive", false, "Mark medias as sensitive by default")
    95 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval")
    97 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval")
    96 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account")
    98 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account")
   677 				source = &madon.SourceParams{}
   679 				source = &madon.SourceParams{}
   678 			}
   680 			}
   679 			source.Sensitive = &opt.defaultSensitive
   681 			source.Sensitive = &opt.defaultSensitive
   680 			change = true
   682 			change = true
   681 		}
   683 		}
   682 
   684 		if accountUpdateFlags.Lookup("profile-field").Changed {
   683 		/*
   685 			var fa = []madon.Field{}
   684 			TODO:
   686 			for _, f := range opt.profileFields {
   685 			updateParams.FieldsAttributes
   687 				kv := strings.SplitN(f, "=", 2)
   686 		*/
   688 				if len(kv) != 2 {
       
   689 					return errors.New("cannot parse field")
       
   690 				}
       
   691 				fa = append(fa, madon.Field{Name: kv[0], Value: kv[1]})
       
   692 			}
       
   693 			updateParams.FieldsAttributes = &fa
       
   694 			change = true
       
   695 		}
   687 
   696 
   688 		if !change { // We want at least one update
   697 		if !change { // We want at least one update
   689 			return errors.New("missing parameters")
   698 			return errors.New("missing parameters")
   690 		}
   699 		}
   691 
   700