cmd/accounts.go
changeset 226 5df927fa87ca
parent 224 d33a2c4fdfbf
child 237 ac5ce4c0e79b
equal deleted inserted replaced
225:f90d1e6d4f15 226:5df927fa87ca
   177 	accountStatusesSubcommand,
   177 	accountStatusesSubcommand,
   178 	accountFollowRequestsSubcommand,
   178 	accountFollowRequestsSubcommand,
   179 	accountFollowSubcommand,
   179 	accountFollowSubcommand,
   180 	accountBlockSubcommand,
   180 	accountBlockSubcommand,
   181 	accountMuteSubcommand,
   181 	accountMuteSubcommand,
       
   182 	accountPinSubcommand,
       
   183 	accountUnpinSubcommand,
   182 	accountRelationshipsSubcommand,
   184 	accountRelationshipsSubcommand,
   183 	accountReportsSubcommand,
   185 	accountReportsSubcommand,
   184 	accountUpdateSubcommand,
   186 	accountUpdateSubcommand,
       
   187 	accountListEndorsementsSubcommand,
   185 }
   188 }
   186 
   189 
   187 var accountSearchSubcommand = &cobra.Command{
   190 var accountSearchSubcommand = &cobra.Command{
   188 	Use:   "search TEXT",
   191 	Use:   "search TEXT",
   189 	Short: "Search for user accounts",
   192 	Short: "Search for user accounts",
   248 }
   251 }
   249 
   252 
   250 var accountMuteSubcommand = &cobra.Command{
   253 var accountMuteSubcommand = &cobra.Command{
   251 	Use:   "mute",
   254 	Use:   "mute",
   252 	Short: "Mute or unmute the account",
   255 	Short: "Mute or unmute the account",
       
   256 	RunE: func(cmd *cobra.Command, args []string) error {
       
   257 		return accountSubcommandsRunE(cmd.Name(), args)
       
   258 	},
       
   259 }
       
   260 
       
   261 var accountPinSubcommand = &cobra.Command{
       
   262 	Use:     "pin",
       
   263 	Short:   "Endorse (pin) the account",
       
   264 	Aliases: []string{"endorse"},
       
   265 	RunE: func(cmd *cobra.Command, args []string) error {
       
   266 		return accountSubcommandsRunE(cmd.Name(), args)
       
   267 	},
       
   268 }
       
   269 
       
   270 var accountUnpinSubcommand = &cobra.Command{
       
   271 	Use:     "unpin",
       
   272 	Short:   "Cancel endorsement of an account",
       
   273 	Aliases: []string{"disavow"},
       
   274 	RunE: func(cmd *cobra.Command, args []string) error {
       
   275 		return accountSubcommandsRunE(cmd.Name(), args)
       
   276 	},
       
   277 }
       
   278 
       
   279 var accountListEndorsementsSubcommand = &cobra.Command{
       
   280 	Use:     "pinned",
       
   281 	Short:   `Display the list of pinned (endorsed) accounts`,
       
   282 	Aliases: []string{"list-endorsements", "get-endorsements"},
   253 	RunE: func(cmd *cobra.Command, args []string) error {
   283 	RunE: func(cmd *cobra.Command, args []string) error {
   254 		return accountSubcommandsRunE(cmd.Name(), args)
   284 		return accountSubcommandsRunE(cmd.Name(), args)
   255 	},
   285 	},
   256 }
   286 }
   257 
   287 
   371 	}
   401 	}
   372 
   402 
   373 	switch subcmd {
   403 	switch subcmd {
   374 	case "show", "search", "update":
   404 	case "show", "search", "update":
   375 		// These subcommands do not require an account ID
   405 		// These subcommands do not require an account ID
   376 	case "favourites", "blocks", "mutes":
   406 	case "favourites", "blocks", "mutes", "pinned":
   377 		// Those subcommands can not use an account ID
   407 		// Those subcommands can not use an account ID
   378 		if opt.accountID > 0 {
   408 		if opt.accountID > 0 {
   379 			return errors.New("useless account ID")
   409 			return errors.New("useless account ID")
   380 		}
   410 		}
   381 	case "follow":
   411 	case "follow":
   571 				muteNotif = &opt.muteNotifications
   601 				muteNotif = &opt.muteNotifications
   572 			}
   602 			}
   573 			relationship, err = gClient.MuteAccount(opt.accountID, muteNotif)
   603 			relationship, err = gClient.MuteAccount(opt.accountID, muteNotif)
   574 		}
   604 		}
   575 		obj = relationship
   605 		obj = relationship
       
   606 	case "pin", "unpin":
       
   607 		var relationship *madon.Relationship
       
   608 		if subcmd == "unpin" {
       
   609 			relationship, err = gClient.UnpinAccount(opt.accountID)
       
   610 		} else {
       
   611 			relationship, err = gClient.PinAccount(opt.accountID)
       
   612 		}
       
   613 		obj = relationship
   576 	case "favourites":
   614 	case "favourites":
   577 		var statusList []madon.Status
   615 		var statusList []madon.Status
   578 		statusList, err = gClient.GetFavourites(limOpts)
   616 		statusList, err = gClient.GetFavourites(limOpts)
   579 		if opt.keep > 0 && len(statusList) > int(opt.keep) {
   617 		if opt.keep > 0 && len(statusList) > int(opt.keep) {
   580 			statusList = statusList[:opt.keep]
   618 			statusList = statusList[:opt.keep]
   588 		}
   626 		}
   589 		obj = accountList
   627 		obj = accountList
   590 	case "mutes":
   628 	case "mutes":
   591 		var accountList []madon.Account
   629 		var accountList []madon.Account
   592 		accountList, err = gClient.GetMutedAccounts(limOpts)
   630 		accountList, err = gClient.GetMutedAccounts(limOpts)
       
   631 		if opt.keep > 0 && len(accountList) > int(opt.keep) {
       
   632 			accountList = accountList[:opt.keep]
       
   633 		}
       
   634 		obj = accountList
       
   635 	case "pinned":
       
   636 		var accountList []madon.Account
       
   637 		accountList, err = gClient.GetEndorsements(limOpts)
   593 		if opt.keep > 0 && len(accountList) > int(opt.keep) {
   638 		if opt.keep > 0 && len(accountList) > int(opt.keep) {
   594 			accountList = accountList[:opt.keep]
   639 			accountList = accountList[:opt.keep]
   595 		}
   640 		}
   596 		obj = accountList
   641 		obj = accountList
   597 	case "relationships":
   642 	case "relationships":