boolean noFormat;
protected void doExecute(FeaturesService featuresService) throws Exception {
boolean needsLegend = false;
ShellTable table = new ShellTable();
table.column("Name");
table.column("Version");
table.column("Required");
table.column("Installed");
table.column("Repository");
table.column("Description").maxSize(50);
table.emptyTableText(onlyInstalled ? "No features installed" : "No features available");
List<Repository> repos = Arrays.asList(featuresService.listRepositories());
for (Repository r : repos) {
List<Feature> features = Arrays.asList(r.getFeatures());
if (ordered) {
Collections.sort(features, new FeatureComparator());
}
for (Feature f : features) {
if (onlyInstalled && !featuresService.isInstalled(f)) {
// Filter out not installed features if we only want to see the installed ones
continue;
}
if (onlyRequired && !featuresService.isRequired(f)) {
// Filter out not installed features if we only want to see the installed ones
continue;
}
if (!showHidden && f.isHidden()) {
// Filter out hidden feature if not asked to display those
continue;
}
table.addRow().addContent(
f.getName(),
f.getVersion(),
featuresService.isRequired(f) ? "x" : "",
featuresService.isInstalled(f) ? "x" : "",
r.getName(),
f.getDescription());
if (isInstalledViaDeployDir(r.getName())) {
needsLegend = true;
}
}
}
table.print(System.out, !noFormat);
if (needsLegend) {
System.out.println("* Installed via deploy directory");
}