fixed nil pointer panic, fixed formatting
This commit is contained in:
parent
1ee3f8c7f3
commit
4d944f552a
4 changed files with 13 additions and 7 deletions
|
@ -69,7 +69,6 @@ func (c *addCommand) addAccountsToList(gtsClient *client.Client) error {
|
|||
}
|
||||
|
||||
fmt.Println("Successfully added the account(s) to the list.")
|
||||
// TODO: ...then print the list with the accounts in them.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -68,8 +68,7 @@ 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.
|
||||
fmt.Println("Successfully removed the account(s) from the list.")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -173,13 +173,17 @@ func (c *showCommand) showList(gts *client.Client) error {
|
|||
return fmt.Errorf("unable to retrieve the list; %w", err)
|
||||
}
|
||||
|
||||
accounts, err := gts.GetAccountsFromList(c.listID, 0)
|
||||
accounts, err := gts.GetAccountsFromList(c.listID, 40)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the accounts from the list; %w", err)
|
||||
}
|
||||
|
||||
if len(accounts) > 0 {
|
||||
accountMap := make(map[string]string)
|
||||
for i := range accounts {
|
||||
list.Accounts[accounts[i].ID] = accounts[i].Username
|
||||
accountMap[accounts[i].ID] = accounts[i].Username
|
||||
}
|
||||
list.Accounts = accountMap
|
||||
}
|
||||
|
||||
fmt.Println(list)
|
||||
|
|
|
@ -99,7 +99,11 @@ func (l List) String() string {
|
|||
|
||||
if len(l.Accounts) > 0 {
|
||||
for id, name := range l.Accounts {
|
||||
output += fmt.Sprintf("- %s (%s)", name, id)
|
||||
output += fmt.Sprintf(
|
||||
"\n - %s (%s)",
|
||||
utilities.DisplayNameFormat(name),
|
||||
id,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
output += "\n None"
|
||||
|
|
Loading…
Reference in a new issue