use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class List method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Name");
table.column("Schedule");
Map<String, ScheduleOptions> jobs = scheduler.getJobs();
for (Map.Entry<String, ScheduleOptions> entry : jobs.entrySet()) {
table.addRow().addContent(entry.getKey(), entry.getValue().schedule());
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class CommandListHelpProvider method printMethodList.
protected void printMethodList(Session session, PrintStream out, SortedMap<String, String> commands, Collection<String> modes) {
boolean list = false;
boolean cyan = false;
int indent = 0;
for (String mode : modes) {
if (mode.equals("list")) {
list = true;
} else if (mode.equals("cyan")) {
cyan = true;
} else if (mode.equals("indent")) {
indent = 3;
} else if (mode.startsWith("indent=")) {
indent = Integer.parseInt(mode.substring("indent=".length())) - 1;
}
}
Terminal term = session.getTerminal();
int termWidth = term != null ? term.getWidth() : 80;
ShellTable table = new ShellTable().noHeaders().separator(" ").size(termWidth - 1);
Col col = new Col("Command").maxSize(64);
if (indent > 0 || list) {
table.column(new Col(""));
}
if (cyan) {
col.cyan();
} else {
col.bold();
}
table.column(col);
table.column(new Col("Description").wrap());
for (Map.Entry<String, String> entry : commands.entrySet()) {
String key = NameScoping.getCommandNameWithoutGlobalPrefix(session, entry.getKey());
if (indent > 0 || list) {
StringBuilder prefix = new StringBuilder();
for (int i = 0; i < indent; i++) {
prefix.append(" ");
}
if (list) {
prefix.append(" *");
}
table.addRow().addContent(prefix.toString(), key, entry.getValue());
} else {
table.addRow().addContent(key, entry.getValue());
}
}
table.print(out, true);
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class AnsiPrintingWikiVisitor method endPara.
@Override
public void endPara() {
if (sb.length() > 0) {
ShellTable table = new ShellTable().noHeaders().separator("").size(maxSize - 1);
table.column("").maxSize(indent.length());
table.column("").wrap();
table.addRow().addContent(indent, sb.toString());
table.print(out);
sb.setLength(0);
} else {
out.println();
}
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListAction method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("ID").alignRight();
table.column("SymbolicName");
table.column("Version");
table.column("State");
table.column("Type");
table.column("Parents");
table.column("Children");
for (Subsystem ss : getSubsystems()) {
table.addRow().addContent(ss.getSubsystemId(), ss.getSymbolicName(), ss.getVersion(), ss.getState().toString(), getType(ss), getSubsytemIds(ss.getParents()), getSubsytemIds(ss.getChildren()));
}
table.print(System.out);
return null;
}
Aggregations