use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.
the class EnsembleListAction method doExecute.
@Override
protected Object doExecute() throws Exception {
TablePrinter printer = new TablePrinter();
printer.column("id");
List<String> containers = clusterService.getEnsembleContainers();
if (containers != null) {
for (String container : containers) {
printer.row(container);
}
}
printer.print();
return null;
}
use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.
the class VersionListAction method printVersions.
protected void printVersions(Container[] containers, List<String> versions, String defaultVersionId, PrintStream out) {
TablePrinter table = new TablePrinter();
table.columns("version", "default", "# containers", "description");
List<String> invalidVersion = new ArrayList<String>();
// they are sorted in the correct order by default
for (String versionId : versions) {
if (versionId != null && !versionId.isEmpty() && ALLOWED_PROFILE_NAMES_PATTERN.matcher(versionId).matches()) {
boolean isDefault = versionId.equals(defaultVersionId);
Version version = profileService.getRequiredVersion(versionId);
int active = countContainersByVersion(containers, version);
String description = version.getAttributes().get(Version.DESCRIPTION);
table.row(version.getId(), (isDefault ? "true" : ""), activeContainerCountText(active), description);
} else {
invalidVersion.add(versionId);
}
}
table.print();
if (!invalidVersion.isEmpty()) {
System.out.println("The following profile versions have been skipped since their names are not correct: " + invalidVersion.toString());
}
}
use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.
the class WatchAction method doExecute.
@Override
protected Object doExecute() throws Exception {
if (start && stop) {
System.err.println("Please use only one of --start and --stop options!");
return null;
}
if (interval > 0) {
System.out.println("Setting watch interval to " + interval + " ms");
watcher.setInterval(interval);
}
if (stop) {
System.out.println("Stopping watch");
watcher.stop();
}
watcher.setUpload(upload);
if (urls != null) {
if (remove) {
for (String url : urls) {
watcher.remove(url);
}
} else {
for (String url : urls) {
watcher.add(url);
}
}
}
if (start) {
System.out.println("Starting watch");
watcher.start();
}
if (list) {
// list the watched bundles.
TablePrinter printer = new TablePrinter();
printer.columns("url", "profile", "version", "bundle");
for (String url : watcher.getWatchURLs()) {
Map<ProfileVersionKey, Map<String, Parser>> profileArtifacts = watcher.getProfileArtifacts();
if (profileArtifacts.size() > 0) {
Set<Map.Entry<ProfileVersionKey, Map<String, Parser>>> entries = profileArtifacts.entrySet();
for (Map.Entry<ProfileVersionKey, Map<String, Parser>> entry : entries) {
ProfileVersionKey key = entry.getKey();
Map<String, Parser> artifactMap = entry.getValue();
Set<Map.Entry<String, Parser>> artifactMapEntries = artifactMap.entrySet();
for (Map.Entry<String, Parser> artifactMapEntry : artifactMapEntries) {
String location = artifactMapEntry.getKey();
Parser parser = artifactMapEntry.getValue();
if (isSnapshot(parser) || watcher.wildCardMatch(location, url)) {
printer.row(url, key.getProfileId(), key.getVersion(), location);
}
}
}
} else {
printer.row(url, "", "", "");
}
}
printer.print();
} else {
List<String> urls = watcher.getWatchURLs();
if (urls != null && urls.size() > 0) {
System.out.println("Watched URLs: ");
for (String url : watcher.getWatchURLs()) {
System.out.println(url);
}
} else {
System.out.println("No watched URLs");
}
}
return null;
}
use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.
the class ArchetypeListAction method doExecute.
@Override
protected Object doExecute() throws Exception {
TablePrinter table = new TablePrinter();
if (verbose) {
table.columns("groupId", "artifactId", "version", "description");
} else {
table.columns("artifactId", "description");
}
for (Archetype archetype : archetypeService.listArchetypes()) {
if (verbose) {
table.row(archetype.groupId, archetype.artifactId, archetype.version, archetype.description);
} else {
// only list artifact id in short format
table.row(archetype.artifactId, archetype.description);
}
}
table.print();
return null;
}
use of io.fabric8.utils.TablePrinter in project fabric8 by jboss-fuse.
the class ContainerListAction method printContainersVerbose.
private void printContainersVerbose(Container[] containers, Version version, PrintStream out) {
TablePrinter table = new TablePrinter();
table.columns("id", "version", "type", "connected", "profiles", "blueprint", "spring", "provision status");
for (Container container : containers) {
if (CommandUtils.matchVersion(container, version)) {
String indent = "";
for (Container c = container; !c.isRoot(); c = c.getParent()) {
indent += " ";
}
// Mark local container with a star symbol
String marker = "";
if (container.getId().equals(fabricService.getCurrentContainer().getId())) {
marker = "*";
}
String blueprintStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.BlueprintStatus, "", false, false);
String springStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.SpringStatus, "", false, false);
blueprintStatus = blueprintStatus.toLowerCase(Locale.ENGLISH);
springStatus = springStatus.toLowerCase(Locale.ENGLISH);
List<String> assignedProfiles = dataStore.getContainerProfiles(container.getId());
table.row(indent + container.getId() + marker, container.getVersion().getId(), container.getType(), aliveText(container), assignedProfiles.get(0), blueprintStatus, springStatus, CommandUtils.status(container));
// we want multiple profiles to be displayed on next lines
for (int i = 1; i < assignedProfiles.size(); i++) {
table.row("", "", "", "", assignedProfiles.get(i), "", "", "");
}
}
}
table.print();
}
Aggregations