Compare commits
No commits in common. "f64f8a43a692027c48b407608f57466566b47aab" and "1541aa69368878b0111bc58a1f63faf5133dfa79" have entirely different histories.
f64f8a43a6
...
1541aa6936
4 changed files with 4 additions and 60 deletions
|
@ -47,7 +47,7 @@ func NewAddExecutor(printer *printer.Printer, config *config.Config, name, summa
|
||||||
addExe.StringVar(&addExe.content, flagContent, "", "The content of the resource")
|
addExe.StringVar(&addExe.content, flagContent, "", "The content of the resource")
|
||||||
addExe.StringVar(&addExe.pollID, flagPollID, "", "The ID of the poll")
|
addExe.StringVar(&addExe.pollID, flagPollID, "", "The ID of the poll")
|
||||||
addExe.Var(&addExe.accountNames, flagAccountName, "The name of the account")
|
addExe.Var(&addExe.accountNames, flagAccountName, "The name of the account")
|
||||||
addExe.Var(&addExe.choices, flagVote, "Add a vote to an option in a poll")
|
addExe.Var(&addExe.choices, flagChoose, "Specify your choice ")
|
||||||
|
|
||||||
addExe.Usage = commandUsageFunc(name, summary, addExe.FlagSet)
|
addExe.Usage = commandUsageFunc(name, summary, addExe.FlagSet)
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ func (a *AddExecutor) addToPoll(gtsClient *client.Client) error {
|
||||||
|
|
||||||
func (a *AddExecutor) addVoteToPoll(gtsClient *client.Client) error {
|
func (a *AddExecutor) addVoteToPoll(gtsClient *client.Client) error {
|
||||||
if len(a.choices) == 0 {
|
if len(a.choices) == 0 {
|
||||||
return errors.New("please use --" + flagVote + " to make a choice in this poll")
|
return errors.New("please use --" + flagChoose + " to make a choice in this poll")
|
||||||
}
|
}
|
||||||
|
|
||||||
poll, err := gtsClient.GetPoll(a.pollID)
|
poll, err := gtsClient.GetPoll(a.pollID)
|
||||||
|
|
|
@ -52,19 +52,6 @@ func (e UnsupportedRemoveOperationError) Error() string {
|
||||||
"' is not supported"
|
"' is not supported"
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnsupportedShowOperationError struct {
|
|
||||||
ResourceType string
|
|
||||||
ShowFromResourceType string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e UnsupportedShowOperationError) Error() string {
|
|
||||||
return "showing '" +
|
|
||||||
e.ResourceType +
|
|
||||||
"' from '" +
|
|
||||||
e.ShowFromResourceType +
|
|
||||||
"' is not supported"
|
|
||||||
}
|
|
||||||
|
|
||||||
type EmptyContentError struct {
|
type EmptyContentError struct {
|
||||||
ResourceType string
|
ResourceType string
|
||||||
Hint string
|
Hint string
|
||||||
|
|
|
@ -16,6 +16,7 @@ const (
|
||||||
flagAccountName = "account-name"
|
flagAccountName = "account-name"
|
||||||
flagAttachmentID = "attachment-id"
|
flagAttachmentID = "attachment-id"
|
||||||
flagBrowser = "browser"
|
flagBrowser = "browser"
|
||||||
|
flagChoose = "choose"
|
||||||
flagContentType = "content-type"
|
flagContentType = "content-type"
|
||||||
flagContent = "content"
|
flagContent = "content"
|
||||||
flagEnableFederation = "enable-federation"
|
flagEnableFederation = "enable-federation"
|
||||||
|
@ -51,7 +52,6 @@ const (
|
||||||
flagTo = "to"
|
flagTo = "to"
|
||||||
flagType = "type"
|
flagType = "type"
|
||||||
flagVisibility = "visibility"
|
flagVisibility = "visibility"
|
||||||
flagVote = "vote"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MultiStringFlagValue []string
|
type MultiStringFlagValue []string
|
||||||
|
|
|
@ -287,26 +287,6 @@ func (s *ShowExecutor) showLists(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowers(gtsClient *client.Client) error {
|
func (s *ShowExecutor) showFollowers(gtsClient *client.Client) error {
|
||||||
if s.fromResourceType == "" {
|
|
||||||
return FlagNotSetError{flagText: flagFrom}
|
|
||||||
}
|
|
||||||
|
|
||||||
funcMap := map[string]func(*client.Client) error{
|
|
||||||
resourceAccount: s.showFollowersFromAccount,
|
|
||||||
}
|
|
||||||
|
|
||||||
doFunc, ok := funcMap[s.fromResourceType]
|
|
||||||
if !ok {
|
|
||||||
return UnsupportedShowOperationError{
|
|
||||||
ResourceType: s.resourceType,
|
|
||||||
ShowFromResourceType: s.fromResourceType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return doFunc(gtsClient)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowersFromAccount(gtsClient *client.Client) error {
|
|
||||||
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
|
@ -327,26 +307,6 @@ func (s *ShowExecutor) showFollowersFromAccount(gtsClient *client.Client) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowing(gtsClient *client.Client) error {
|
func (s *ShowExecutor) showFollowing(gtsClient *client.Client) error {
|
||||||
if s.fromResourceType == "" {
|
|
||||||
return FlagNotSetError{flagText: flagFrom}
|
|
||||||
}
|
|
||||||
|
|
||||||
funcMap := map[string]func(*client.Client) error{
|
|
||||||
resourceAccount: s.showFollowingFromAccount,
|
|
||||||
}
|
|
||||||
|
|
||||||
doFunc, ok := funcMap[s.fromResourceType]
|
|
||||||
if !ok {
|
|
||||||
return UnsupportedShowOperationError{
|
|
||||||
ResourceType: s.resourceType,
|
|
||||||
ShowFromResourceType: s.fromResourceType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return doFunc(gtsClient)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowingFromAccount(gtsClient *client.Client) error {
|
|
||||||
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
|
@ -489,10 +449,7 @@ func (s *ShowExecutor) showMedia(gtsClient *client.Client) error {
|
||||||
|
|
||||||
doFunc, ok := funcMap[s.fromResourceType]
|
doFunc, ok := funcMap[s.fromResourceType]
|
||||||
if !ok {
|
if !ok {
|
||||||
return UnsupportedShowOperationError{
|
return fmt.Errorf("do not support viewing media from %s", s.fromResourceType)
|
||||||
ResourceType: s.resourceType,
|
|
||||||
ShowFromResourceType: s.fromResourceType,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doFunc(gtsClient)
|
return doFunc(gtsClient)
|
||||||
|
|
Loading…
Reference in a new issue