@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Override public void removedService(ServiceReference<Object> reference, List<Command> commands) { for (Command command : commands) { sessionFactory.getRegistry().unregister(command); } } }
private int getTermWidth() { Terminal term = session.getTerminal(); return term != null ? term.getWidth() : 80; }
@Override public String[] interactive(ClientSession s, String name, String instruction, String lang, String[] prompt, boolean[] echo) { String[] answers = new String[prompt.length]; try { for (int i = 0; i < prompt.length; i++) { answers[i] = session.readLine(prompt[i] + " ", echo[i] ? null : '*'); } } catch (IOException e) { } return answers; } @Override
@Override public CommandLine parse(Session session, String command, int cursor) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).parse(session, command, cursor); } throw new IllegalStateException("Could not find specified parser"); }
private int getTermHeight() { Terminal term = session.getTerminal(); return term != null ? term.getHeight() : 25; }
@Override public String preprocess(Session session, CommandLine commandLine) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).preprocess(session, commandLine); } throw new IllegalStateException("Could not find specified parser"); } }
@Override public String word() { return cmdLine.getCursorArgument(); } @Override
@Override public String line() { return cmdLine.getBuffer(); } @Override
private CharSequence filter(CharSequence command) { for (CommandLoggingFilter filter : filters) { command = filter.filter(command); } return command; }
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { // buffer could be null assert candidates != null; for (Completer completer : completers) { completer.completeCandidates(session, commandLine, candidates); } }
@Override public void removedService(ServiceReference<Object> reference, List<Command> commands) { for (Command command : commands) { sessionFactory.getRegistry().unregister(command); } } }
private int getTermWidth() { Terminal term = session.getTerminal(); return term != null ? term.getWidth() : 80; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
@Override public CommandLine parse(Session session, String command, int cursor) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).parse(session, command, cursor); } throw new IllegalStateException("Could not find specified parser"); }
private int getTermHeight() { Terminal term = session.getTerminal(); return term != null ? term.getHeight() : 25; }
@Override public String preprocess(Session session, CommandLine commandLine) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).preprocess(session, commandLine); } throw new IllegalStateException("Could not find specified parser"); } }