checkpoint: add a model for list of lists

This commit is contained in:
Dan Anglin 2024-05-18 20:39:57 +01:00
parent 5e52119158
commit 605df92b37
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
5 changed files with 24 additions and 5 deletions

View file

@ -68,5 +68,8 @@ func (c *addCommand) addAccountsToList(gtsClient *client.Client) error {
return fmt.Errorf("unable to add the accounts to the list; %w", err)
}
fmt.Println("Successfully added the account(s) to the list.")
// TODO: ...then print the list with the accounts in them.
return nil
}

View file

@ -68,5 +68,8 @@ func (c *removeCommand) removeAccountsFromList(gtsClient *client.Client) error {
return fmt.Errorf("unable to remove the accounts from the list; %w", err)
}
fmt.Println("Successfully removed the account(s) to the list.")
// TODO: ...then print the list with the accounts in them.
return nil
}

View file

@ -176,10 +176,7 @@ func (c *showCommand) showLists(gts *client.Client) error {
}
fmt.Println(utilities.HeaderFormat("LISTS"))
for i := range lists {
fmt.Printf("\n%s\n", lists[i])
}
fmt.Println(lists)
return nil
}

View file

@ -13,7 +13,7 @@ const (
listPath string = "/api/v1/lists"
)
func (g *Client) GetAllLists() ([]model.List, error) {
func (g *Client) GetAllLists() (model.Lists, error) {
url := g.Authentication.Instance + listPath
var lists []model.List

View file

@ -87,3 +87,19 @@ func (l List) String() string {
utilities.FieldFormat("Replies Policy:"), l.RepliesPolicy,
)
}
type Lists []List
func (l Lists) String() string {
output := ""
for i := range l {
output += fmt.Sprintf(
"\n%s (%s)",
l[i].Title,
l[i].ID,
)
}
return output
}