Compare commits
2 commits
4db116121c
...
605df92b37
Author | SHA1 | Date | |
---|---|---|---|
605df92b37 | |||
5e52119158 |
6 changed files with 28 additions and 5 deletions
|
@ -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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ func run() error {
|
||||||
updateResource string = "update"
|
updateResource string = "update"
|
||||||
whoami string = "whoami"
|
whoami string = "whoami"
|
||||||
add string = "add"
|
add string = "add"
|
||||||
|
remove string = "remove"
|
||||||
)
|
)
|
||||||
|
|
||||||
summaries := map[string]string{
|
summaries := map[string]string{
|
||||||
|
@ -65,6 +66,7 @@ func run() error {
|
||||||
updateResource: "update a specific resource",
|
updateResource: "update a specific resource",
|
||||||
whoami: "print the account that you are currently logged in to",
|
whoami: "print the account that you are currently logged in to",
|
||||||
add: "add a resource to another resource",
|
add: "add a resource to another resource",
|
||||||
|
remove: "remove a resource from another resource",
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Usage = enbasUsageFunc(summaries)
|
flag.Usage = enbasUsageFunc(summaries)
|
||||||
|
@ -101,6 +103,8 @@ func run() error {
|
||||||
executor = newWhoAmICommand(whoami, summaries[whoami])
|
executor = newWhoAmICommand(whoami, summaries[whoami])
|
||||||
case add:
|
case add:
|
||||||
executor = newAddCommand(add, summaries[add])
|
executor = newAddCommand(add, summaries[add])
|
||||||
|
case remove:
|
||||||
|
executor = newRemoveCommand(remove, summaries[remove])
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
return fmt.Errorf("unknown subcommand %q", subcommand)
|
return fmt.Errorf("unknown subcommand %q", subcommand)
|
||||||
|
|
|
@ -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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,10 +176,7 @@ func (c *showCommand) showLists(gts *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(utilities.HeaderFormat("LISTS"))
|
fmt.Println(utilities.HeaderFormat("LISTS"))
|
||||||
|
fmt.Println(lists)
|
||||||
for i := range lists {
|
|
||||||
fmt.Printf("\n%s\n", lists[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ const (
|
||||||
listPath string = "/api/v1/lists"
|
listPath string = "/api/v1/lists"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Client) GetAllLists() ([]model.List, error) {
|
func (g *Client) GetAllLists() (model.Lists, error) {
|
||||||
url := g.Authentication.Instance + listPath
|
url := g.Authentication.Instance + listPath
|
||||||
|
|
||||||
var lists []model.List
|
var lists []model.List
|
||||||
|
|
|
@ -87,3 +87,19 @@ func (l List) String() string {
|
||||||
utilities.FieldFormat("Replies Policy:"), l.RepliesPolicy,
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue