Search in sources :

Example 56 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) ScheduleOptions(org.apache.karaf.scheduler.ScheduleOptions) Map(java.util.Map)

Example 57 with ShellTable

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);
}
Also used : Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Terminal(org.apache.karaf.shell.api.console.Terminal) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 58 with ShellTable

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();
    }
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 59 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Subsystem(org.osgi.service.subsystem.Subsystem)

Aggregations

ShellTable (org.apache.karaf.shell.support.table.ShellTable)59 Row (org.apache.karaf.shell.support.table.Row)10 Col (org.apache.karaf.shell.support.table.Col)7 ArrayList (java.util.ArrayList)4 Bundle (org.osgi.framework.Bundle)4 Map (java.util.Map)3 Feature (org.apache.karaf.features.Feature)3 Repository (org.apache.karaf.features.Repository)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Bus (org.apache.cxf.Bus)2 Booking (org.apache.karaf.examples.jdbc.api.Booking)2 Booking (org.apache.karaf.examples.jpa.Booking)2 MavenRepositoryURL (org.apache.karaf.maven.core.MavenRepositoryURL)2 Attribute (ddf.catalog.data.Attribute)1 Result (ddf.catalog.data.Result)1 SortByImpl (ddf.catalog.filter.impl.SortByImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1