}
@Override protected Map<String, String> _run() {
Output.print(description);
boolean hadResults = false;
SearchResult searchResults = RestTemplate.get(url, new TypeReference<SearchResult>() { });
if (searchResults == null) {
Output.print("^red^Invalid query.^r^");
return Collections.emptyMap();
}
Map<String, String> wrkIds = new HashMap<String, String>();
if (!searchResults.getOrganizations().isEmpty()) {
Output.print("Found ^b^%d organization%s%s^r^.", searchResults.getOrganizations().size(),
(searchResults.getOrganizations().size() == 1 ? "" : "s"), (searchResults.getOrganizations().size() == 1000 ? " (limited to 1000)" : ""));
hadResults = true;
wrkIds.putAll(Orgs.printOrgs(searchResults.getOrganizations(), wrkIds.size() + 1));
}
if (!searchResults.getBoards().isEmpty()) {
Output.print("Found ^b^%d board%s%s^r^.", searchResults.getBoards().size(),
(searchResults.getBoards().size() == 1 ? "" : "s"), (searchResults.getBoards().size() == 1000 ? " (limited to 1000)" : ""));
hadResults = true;
wrkIds.putAll(Boards.printBoards(searchResults.getBoards(), wrkIds.size() + 1));
}
if (!searchResults.getCards().isEmpty()) {
Output.print("Found ^b^%d card%s%s^r^.", searchResults.getCards().size(),
(searchResults.getCards().size() == 1 ? "" : "s"), (searchResults.getCards().size() == 1000 ? " (limited to 1000)" : ""));
hadResults = true;
wrkIds.putAll(Cards.printCards(searchResults.getCards(), wrkIds.size() + 1));
}
if (!searchResults.getMembers().isEmpty()) {
Output.print("Found ^b^%d member%s%s^r^.", searchResults.getMembers().size(),
(searchResults.getMembers().size() == 1 ? "" : "s"), (searchResults.getMembers().size() == 1000 ? " (limited to 1000)" : ""));
hadResults = true;
wrkIds.putAll(Members.printMembers(searchResults.getMembers(), wrkIds.size() + 1));
}
// TODO - actions?
if (!hadResults) {
Output.print("^black^No results.^r^");
}