@Override public Set<String> getCommands() { return factory.getRegistry().getCommands().stream() .map(c -> c.getScope() + ":" + c.getName()) .collect(Collectors.toSet()); } @Override
@Override public Set<String> getCommands() { return factory.getRegistry().getCommands().stream() .map(c -> c.getScope() + ":" + c.getName()) .collect(Collectors.toSet()); } @Override
/** * {@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 String resolveCommand(String name) { // TODO: optimize if (!name.contains(":")) { String[] scopes = ((String) get(Session.SCOPE)).split(":"); List<Command> commands = registry.getCommands(); for (String scope : scopes) { for (Command command : commands) { if ((Session.SCOPE_GLOBAL.equals(scope) || command.getScope().equals(scope)) && command.getName().equals(name)) { return command.getScope() + ":" + name; } } } } return name; }
@Override public String resolveCommand(String name) { // TODO: optimize if (!name.contains(":")) { String[] scopes = ((String) get(Session.SCOPE)).split(":"); List<Command> commands = registry.getCommands(); for (String scope : scopes) { for (Command command : commands) { if ((Session.SCOPE_GLOBAL.equals(scope) || command.getScope().equals(scope)) && command.getName().equals(name)) { return command.getScope() + ":" + name; } } } } return name; }
@Override public String resolveCommand(String name) { // TODO: optimize if (!name.contains(":")) { String[] scopes = ((String) get(Session.SCOPE)).split(":"); List<Command> commands = registry.getCommands(); for (String scope : scopes) { boolean globalScope = Session.SCOPE_GLOBAL.equals(scope); for (Command command : commands) { if ((globalScope || command.getScope().equals(scope)) && command.getName().equals(name)) { return command.getScope() + ":" + name; } } } } return name; }
@Override public String resolveCommand(String name) { // TODO: optimize if (!name.contains(":")) { String[] scopes = ((String) get(Session.SCOPE)).split(":"); List<Command> commands = registry.getCommands(); for (String scope : scopes) { boolean globalScope = Session.SCOPE_GLOBAL.equals(scope); for (Command command : commands) { if ((globalScope || command.getScope().equals(scope)) && command.getName().equals(name)) { return command.getScope() + ":" + name; } } } } return name; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (command != null && !name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (command != null && !name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (!name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
@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; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (command != null && !name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (command != null && !name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
@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; }
private Set<Command> getCommands(Session session, String path) { // TODO: this is not really clean List<Command> commands = session.getRegistry().getCommands(); String subshell = (String) session.get(Session.SUBSHELL); String completionMode = (String) session.get(Session.COMPLETION_MODE); Set<Command> matchingCommands = new HashSet<>(); for (Command command : commands) { String name = command.getScope() + ":" + command.getName(); if (!name.startsWith(path)) { continue; } if (completionMode != null && completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL)) { // filter the help only for "global" commands if (subshell == null || subshell.trim().isEmpty()) { if (!name.startsWith(Session.SCOPE_GLOBAL)) { continue; } } } if (completionMode != null && (completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_SUBSHELL) || completionMode.equalsIgnoreCase(Session.COMPLETION_MODE_FIRST))) { // filter the help only for commands local to the subshell if (!name.startsWith(subshell)) { continue; } } matchingCommands.add(command); } return matchingCommands; }
for (Command cmd : session.getRegistry().getCommands()) { if (name.equals(cmd.getScope() + ":" + cmd.getName())) { cmdParser = cmd.getParser();
for (Command cmd : session.getRegistry().getCommands()) { if (name.equals(cmd.getScope() + ":" + cmd.getName())) { cmdParser = cmd.getParser();
for (Command cmd : session.getRegistry().getCommands()) { if (name.equals(cmd.getScope() + ":" + cmd.getName())) { cmdParser = cmd.getParser();
for (Command command : session.getRegistry().getCommands()) { if (!Session.SCOPE_GLOBAL.equals(command.getScope())) { completer.getStrings().add(command.getScope() + ":" + command.getName());
for (Command command : session.getRegistry().getCommands()) { if (!Session.SCOPE_GLOBAL.equals(command.getScope())) { completer.getStrings().add(command.getScope() + ":" + command.getName());