Search in sources :

Example 1 with StringsCompleter

use of org.apache.karaf.shell.support.completers.StringsCompleter in project camel by apache.

the class CamelContextCompleter method complete.

public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    try {
        StringsCompleter delegate = new StringsCompleter();
        List<CamelContext> camelContexts = getLocalCamelContexts();
        for (CamelContext camelContext : camelContexts) {
            delegate.getStrings().add(camelContext.getName());
        }
        return delegate.complete(session, commandLine, candidates);
    } catch (Exception e) {
    // nothing to do, no completion
    }
    return 0;
}
Also used : CamelContext(org.apache.camel.CamelContext) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter)

Example 2 with StringsCompleter

use of org.apache.karaf.shell.support.completers.StringsCompleter in project camel by apache.

the class RouteCompleter method complete.

public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    try {
        StringsCompleter delegate = new StringsCompleter();
        List<Map<String, String>> routes = getRoutes(null);
        for (Map<String, String> row : routes) {
            delegate.getStrings().add(row.get("routeId"));
        }
        return delegate.complete(session, commandLine, candidates);
    } catch (Exception e) {
    // nothing to do, no completion
    }
    return 0;
}
Also used : StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) Map(java.util.Map)

Example 3 with StringsCompleter

use of org.apache.karaf.shell.support.completers.StringsCompleter in project opennms by OpenNMS.

the class AliasCompleter method complete.

public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    // Gather the list of known aliases
    delegate.getStrings().addAll(secureCredentialsVault.getAliases());
    return delegate.complete(session, commandLine, candidates);
}
Also used : StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter)

Example 4 with StringsCompleter

use of org.apache.karaf.shell.support.completers.StringsCompleter in project karaf by apache.

the class CommandNamesCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // TODO: optimize
    List<Command> list = session.getRegistry().getCommands();
    Set<String> names = new HashSet<>();
    for (Command command : list) {
        names.add(command.getScope() + ":" + command.getName());
        names.add(command.getName());
    }
    int res = new StringsCompleter(names).complete(session, commandLine, candidates);
    Collections.sort(candidates);
    return res;
}
Also used : Command(org.apache.karaf.shell.api.console.Command) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) HashSet(java.util.HashSet)

Example 5 with StringsCompleter

use of org.apache.karaf.shell.support.completers.StringsCompleter in project karaf by apache.

the class ServicesIdCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    Bundle[] bundles = bundleContext.getBundles();
    for (Bundle bundle : bundles) {
        ServiceReference[] references = bundle.getRegisteredServices();
        if (references != null) {
            for (ServiceReference reference : references) {
                if (reference.getProperty(Constants.SERVICE_ID) != null) {
                    delegate.getStrings().add(reference.getProperty(Constants.SERVICE_ID).toString());
                }
            }
        }
    }
    return delegate.complete(session, commandLine, candidates);
}
Also used : StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) Bundle(org.osgi.framework.Bundle) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)12 ArrayList (java.util.ArrayList)4 Completer (org.apache.karaf.shell.api.console.Completer)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Command (org.apache.karaf.shell.api.console.Command)2 File (java.io.File)1 Collection (java.util.Collection)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 CamelContext (org.apache.camel.CamelContext)1 CommandLine (org.apache.karaf.shell.api.console.CommandLine)1 Session (org.apache.karaf.shell.api.console.Session)1 ArgumentCommandLine (org.apache.karaf.shell.support.completers.ArgumentCommandLine)1 FileCompleter (org.apache.karaf.shell.support.completers.FileCompleter)1 NullCompleter (org.apache.karaf.shell.support.completers.NullCompleter)1 UriCompleter (org.apache.karaf.shell.support.completers.UriCompleter)1