/** * {@link Action}.{@link #execute()} will be called on the CommandWrapper instance created by Karaf (see * {@link CommandWrapper} default constructor). */ @Override public Object execute() throws Exception { List<Command> commands = registry.getCommands(); for (Command command : commands) { if (command.getScope().equals(SCOPE) && command instanceof CommandWrapper) { command.execute(null, Arrays.asList(new Object[] { "--help" })); } } return null; }
@Override public Completer getCompleter(boolean scoped) { return command.getCompleter(scoped); }
@Override public String getDescription() { return command.getDescription(); }
for (Command command : commands) { String subshell = (String) session.get(Session.SUBSHELL); String name = command.getScope() + ":" + command.getName(); String description = command.getDescription(); if (name.startsWith("*:")) { name = name.substring(2);
String key = command.getScope() + ":" + command.getName(); Completer cg = command.getCompleter(false); Completer cl = command.getCompleter(true); if (cg == null) { if (Session.SCOPE_GLOBAL.equals(command.getScope())) { cg = new FixedSimpleCommandCompleter(Collections.singletonList(command.getName())); } else { cg = new FixedSimpleCommandCompleter(Arrays.asList(key, command.getName())); cl = new FixedSimpleCommandCompleter(Collections.singletonList(command.getName()));
@Override public Object execute(final CommandSession commandSession, List<Object> arguments) throws Exception { // TODO: remove the hack for .session Session session = (Session) commandSession.get(".session"); // When need to translate closures to a compatible type for the command for (int i = 0; i < arguments.size(); i++) { Object v = arguments.get(i); if (v instanceof Closure) { final Closure closure = (Closure) v; arguments.set(i, (org.apache.karaf.shell.api.console.Function) (s, a) -> closure.execute(commandSession, a)); } } return command.execute(session, arguments); }
public String getScope() { return command.getScope(); }
public String getName() { return command.getName(); }
String[] parts = cmdName.split(":"); Command cmd = parts.length == 2 ? session.getRegistry().getCommand(parts[0], parts[1]) : null; Parser cmdParser = cmd != null ? cmd.getParser() : null; if (cmdParser != null) { final CommandLine cmdLine = cmdParser.parse(session, statement.toString(), cursor - statement.start());
for (Command command : commands) { String subshell = (String) session.get(Session.SUBSHELL); String name = command.getScope() + ":" + command.getName(); String description = command.getDescription(); if (name.startsWith("*:")) { name = name.substring(2);
String key = command.getScope() + ":" + command.getName(); Completer cg = command.getCompleter(false); Completer cl = command.getCompleter(true); if (cg == null) { if (Session.SCOPE_GLOBAL.equals(command.getScope())) { cg = new FixedSimpleCommandCompleter(Collections.singletonList(command.getName())); } else { cg = new FixedSimpleCommandCompleter(Arrays.asList(key, command.getName())); cl = new FixedSimpleCommandCompleter(Collections.singletonList(command.getName()));
@Override public Object execute(final CommandSession commandSession, List<Object> arguments) throws Exception { // TODO: remove the hack for .session Session session = (Session) commandSession.get(".session"); // When need to translate closures to a compatible type for the command for (int i = 0; i < arguments.size(); i++) { Object v = arguments.get(i); if (v instanceof Closure) { final Closure closure = (Closure) v; arguments.set(i, (org.apache.karaf.shell.api.console.Function) (s, a) -> closure.execute(commandSession, a)); } } return command.execute(session, arguments); }
public String getScope() { return command.getScope(); }
public String getName() { return command.getName(); }
String[] parts = cmdName.split(":"); Command cmd = parts.length == 2 ? session.getRegistry().getCommand(parts[0], parts[1]) : null; Parser cmdParser = cmd != null ? cmd.getParser() : null; if (cmdParser != null) { final CommandLine cmdLine = cmdParser.parse(session, statement.toString(), cursor - statement.start());