use of com.google.gerrit.server.ioutil.ColumnFormatter in project gerrit by GerritCodeReview.
the class ListGroupsCommand method run.
@Override
public void run() throws Exception {
enableGracefulStop();
if (listGroups.getUser() != null && !listGroups.getProjects().isEmpty()) {
throw die("--user and --project options are not compatible.");
}
ColumnFormatter formatter = new ColumnFormatter(stdout, '\t');
for (GroupInfo info : listGroups.get()) {
formatter.addColumn(MoreObjects.firstNonNull(info.name, "n/a"));
if (verboseOutput) {
Optional<InternalGroup> group = info.ownerId != null ? groupCache.get(AccountGroup.uuid(Url.decode(info.ownerId))) : Optional.empty();
formatter.addColumn(Url.decode(info.id));
formatter.addColumn(Strings.nullToEmpty(info.description));
formatter.addColumn(group.map(InternalGroup::getName).orElse("n/a"));
formatter.addColumn(group.map(g -> g.getGroupUUID().get()).orElse(""));
formatter.addColumn(Boolean.toString(MoreObjects.firstNonNull(info.options.visibleToAll, Boolean.FALSE)));
}
formatter.nextLine();
}
formatter.finish();
}
Aggregations