Compare commits

..

14 commits

Author SHA1 Message Date
03beb6ab30
liking and unliking statuses 2024-07-03 18:59:01 +01:00
3324cd7a4c
checkpoint: status actions 2024-07-03 17:43:10 +01:00
ab415816af
followers and followings 2024-07-03 14:49:18 +01:00
9a2e4724ec
private note 2024-07-03 14:32:53 +01:00
084814c6d1
timelines, follow requests 2024-07-03 14:32:53 +01:00
56ea3f55c8
polls 2024-07-03 14:32:53 +01:00
4911a7c464
add a ToC to manual 2024-07-03 14:32:53 +01:00
25b7e64228
checkpoint: list section complete 2024-07-03 14:32:52 +01:00
c1d1aa7759
checkpoint: more work on user manual 2024-07-03 14:32:52 +01:00
124b4dc8e8
checkpoint: document account actions 2024-07-03 14:32:52 +01:00
35666f39b7
checkpoint: begin writing the user manual 2024-07-03 14:32:52 +01:00
f64f8a43a6
fix: command line format for showing followers
CHANGES:

- When viewing followers and followings from an account, the from flag
  must now be set by the user.
    - enbas show --type followers --from account --my-account
    - enbas show --type following --from account --account-name john

- New error type for unsupported show operations: Return an error if
  enbas detects an unsupported show operation (e.g. showing media from a
  list).
2024-07-03 14:20:25 +01:00
a8aeec2fbf
fix: update description for the vote flag 2024-07-03 13:34:27 +01:00
5ec1cc0e18
fix: rename the choose flag.
Rename to choose flag to vote for voting in polls.
2024-07-03 13:21:32 +01:00
5 changed files with 161 additions and 17 deletions

View file

@ -21,14 +21,16 @@ SPDX-License-Identifier: CC-BY-4.0
- [View an account](#view-an-account)
- [Follow an account](#follow-an-account)
- [Unfollow an account](#unfollow-an-account)
- [Show followers of an account](#show-followers-of-an-account)
- [Show who an account is following](#show-who-an-account-is-following)
- [Show an account's followers](#show-an-accounts-followers)
- [Show account's followings](#show-accounts-followings)
- [Block an account](#block-an-account)
- [Unblock an account](#unblock-an-account)
- [View blocked accounts](#view-blocked-accounts)
- [Mute an account](#mute-an-account)
- [Unmute an account](#unmute-an-account)
- [View muted accounts](#view-muted-accounts)
- [Add a private note to an account](#add-a-private-note-to-an-account)
- [Remove the private note from an account](#remove-the-private-note-from-an-account)
- [Follow requests](#follow-requests)
- [View your follow requests](#view-your-follow-requests)
- [Accept a follow request](#accept-a-follow-request)
@ -41,6 +43,7 @@ SPDX-License-Identifier: CC-BY-4.0
- [Un-boost (Un-repost) a status](#un-boost-un-repost-a-status)
- [Like a status](#like-a-status)
- [Unlike a status](#unlike-a-status)
- [View a list of statuses that you've liked](#view-a-list-of-statuses-that-youve-liked)
- [Mute a status](#mute-a-status)
- [Unmute a status](#unmute-a-status)
- [Polls](#polls)
@ -132,7 +135,7 @@ enbas whoami
### View your own account
Print the information of your own account.
Prints the information from your own account.
```
enbas show --type account --my-account
@ -161,7 +164,7 @@ enbas show --type account --account-name @name@example.social
### Follow an account
Send a follow request to the account you want to follow.
Sends a follow request to the account you want to follow.
```
enbas follow --type account --account-name @name@example.social
@ -176,7 +179,7 @@ enbas follow --type account --account-name @name@example.social
### Unfollow an account
Unfollow the account that you are currently following.
Unfollows the account that you are currently following.
If you have a follow request pending for the account in question,
performing an unfollow action will remove said follow request.
@ -191,11 +194,39 @@ enbas unfollow --type account --account-name @name@example.social
### Show an account's followers
_TODO: provide instructions after updated implementation_
- View followers of your own account.
```
enbas show --type followers --from account --my-account
```
- View followers of another account.
```
enbas show --type followers --from account --account-name @name@example.social
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to view. Here this should be `followers`. | |
| `from` | string | true | The resource you want to view followers from.<br>Here this should be `account`. | |
| `my-account` | boolean | false | Set to `true` to view followers from your own account.<br>This takes precendence over `account-name`.| false |
| `account-name` | string | true | The name of the account to get the followers from. | |
### Show account's followings
_TODO: provide instructions after updated implementation_
- View the accounts that you are following.
```
enbas show --type following --from account --my-account
```
- View the accounts that another account is following.
```
enbas show --type following --from account --account-name @name@example.social
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to view. Here this should be `following`. | |
| `from` | string | true | The resource you want to view the followings from.<br>Here this should be `account`. | |
| `my-account` | boolean | false | Set to `true` to view the list from your own account.<br>This takes precendence over `account-name`.| false |
| `account-name` | string | true | The name of the account to get the list from. | |
### Block an account
@ -313,6 +344,8 @@ enbas show --type follow-request
### Accept a follow request
Accepts the request from the account that wants to follow you.
```
enbas accept --type follow-request --account-name @person.example.social
```
@ -324,6 +357,8 @@ enbas accept --type follow-request --account-name @person.example.social
### Reject a follow request
Rejects the request from the account that wants to follow you.
```
enbas reject --type follow-request --account-name @person.example.social
```
@ -349,19 +384,72 @@ _Not yet supported_
### Boost (Repost) a status
To boost a status you simply add a `boost` to it.
To boost a status, simply add a `boost` to it.
```
enbas add --type boost --to status --status-id 01J17FH1KD9CN6J9Q01011NE0D
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to add.<br>Here this should be `boost`. | |
| `to` | string | true | The resource you want to add the boost to.<br>Here this should be `status`. | |
| `status-id` | string | true | The ID of the status that you want to boost. | |
### Un-boost (Un-repost) a status
To un-boost a status that you've boosted you simply remove the `boost` from it.
To un-boost a status that you've boosted, simply remove the `boost` from it.
```
enbas remove --type boost --from status --status-id 01J17FH1KD9CN6J9Q01011NE0D
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to add.<br>Here this should be `boost`. | |
| `from` | string | true | The resource you want to remove the boost from.<br>Here this should be `status`. | |
| `status-id` | string | true | The ID of the status that you want to un-boost. | |
### Like a status
To like (favourite) a status you simply add a `like` or a `star` to it.
To like (favourite) a status, simply add a `like` or a `star` to it.
```
enbas add --type star --to status --status-id 01J17FH1KD9CN6J9Q01011NE0D
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to add.<br>Here this should either be `like` or `star`. | |
| `to` | string | true | The resource you want to like.<br>Here this should be `status`. | |
| `status-id` | string | true | The ID of the status that you want to like. | |
### Unlike a status
To unlike (un-favourite) a status that you've previously liked you simply remove the `like` or `star` from it.
To unlike (un-favourite) a status that you've previously liked, simply remove the `like` or `star` from it.
```
enbas remove --type star --from status --status-id 01J17FH1KD9CN6J9Q01011NE0D
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to add.<br>Here this should either be `like` or `star`. | |
| `from` | string | true | The resource you want to remove the like from.<br>Here this should be `status`. | |
| `status-id` | string | true | The ID of the status that you want to remove the like from. | |
### View a list of statuses that you've liked
Prints the list of statuses that you've liked.
```
enbas show --type liked
```
| flag | type | required | description | default |
|------|------|----------|-------------|---------|
| `type` | string | true | The resource you want to view.<br>Here this should either be `liked` or `starred`. | |
| `limit` | integer | false | The maximum number of statuses to print. | 20 |
### Mute a status
@ -395,7 +483,7 @@ enbas show --type poll --poll-id 01J0CEEZBZ6E6AYQSJPHCQYBDA
Add your vote(s) to a poll.
```
enbas add --type vote --to poll --poll-id 01J1TVJ705VV3VP02FVVBSMX7E --choose 3
enbas add --type vote --to poll --poll-id 01J1TVJ705VV3VP02FVVBSMX7E --vote 3
```
| flag | type | required | description | default |
@ -403,7 +491,7 @@ enbas add --type vote --to poll --poll-id 01J1TVJ705VV3VP02FVVBSMX7E --choose 3
| `type` | string | true | The resource you want to add.<br>Here this should be `vote`. | |
| `to` | string | true | The resource you want to add the vote to.<br>Here this should be `poll`. | |
| `poll-id` | string | true | The ID of the poll you want to add the votes to. | |
| `choose` | int | true | The ID of the option that you want to vote for.<br>You can use this flag multiple times to vote for more than one option if the poll allows multiple choices. | |
| `vote` | int | true | The ID of the option that you want to vote for.<br>You can use this flag multiple times to vote for more than one option if the poll allows multiple choices. | |
## Lists

View file

@ -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.pollID, flagPollID, "", "The ID of the poll")
addExe.Var(&addExe.accountNames, flagAccountName, "The name of the account")
addExe.Var(&addExe.choices, flagChoose, "Specify your choice ")
addExe.Var(&addExe.choices, flagVote, "Add a vote to an option in a poll")
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 {
if len(a.choices) == 0 {
return errors.New("please use --" + flagChoose + " to make a choice in this poll")
return errors.New("please use --" + flagVote + " to make a choice in this poll")
}
poll, err := gtsClient.GetPoll(a.pollID)

View file

@ -52,6 +52,19 @@ func (e UnsupportedRemoveOperationError) Error() string {
"' 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 {
ResourceType string
Hint string

View file

@ -16,7 +16,6 @@ const (
flagAccountName = "account-name"
flagAttachmentID = "attachment-id"
flagBrowser = "browser"
flagChoose = "choose"
flagContentType = "content-type"
flagContent = "content"
flagEnableFederation = "enable-federation"
@ -52,6 +51,7 @@ const (
flagTo = "to"
flagType = "type"
flagVisibility = "visibility"
flagVote = "vote"
)
type MultiStringFlagValue []string

View file

@ -287,6 +287,26 @@ func (s *ShowExecutor) showLists(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)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
@ -307,6 +327,26 @@ func (s *ShowExecutor) showFollowers(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)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
@ -449,7 +489,10 @@ func (s *ShowExecutor) showMedia(gtsClient *client.Client) error {
doFunc, ok := funcMap[s.fromResourceType]
if !ok {
return fmt.Errorf("do not support viewing media from %s", s.fromResourceType)
return UnsupportedShowOperationError{
ResourceType: s.resourceType,
ShowFromResourceType: s.fromResourceType,
}
}
return doFunc(gtsClient)