@Test public void completeFormats() { ArrayList<CharSequence> r = new ArrayList<>(); complete("set format h", r); assertEquals(1, r.size()); assertEquals("html", r.get(0)); r = new ArrayList<>(); complete("set format", r); assertEquals(5, r.size()); }
@Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { boolean allparsed; Set<Candidate> result = new TreeSet<>(); try { Result pr = ShellCommandParser.parse(line.line(), excludedCommands); if (pr.getFirstCommand() == HelpCommand.class || pr.getFirstCommand() == ShellHelpCommand.class) { pr = ShellCommandParser.parse(pr.getRemainingArgs(), excludedCommands); } if (pr.getRemainingArgs().length > 1) { } else { OptionGroup<ID> options; if (pr.getLastCommand() == null) { options = OptionIntrospector.introspect(CSLTool.class, AdditionalShellCommands.class); } else { options = OptionIntrospector.introspect(pr.getLastCommand()); } String[] ra = pr.getRemainingArgs(); allparsed = (ra == null || ra.length == 0); for (Option<ID> o : options.getCommands()) { Class<? extends Command> cmd = OptionIntrospector.getCommand(o.getId()); if (excludedCommands.contains(cmd)) { continue; } if (allparsed || o.getLongName().startsWith(ra[0])) { result.add(new Candidate(o.getLongName())); } } } if (pr.getLastCommand() != null && Completer.class.isAssignableFrom(pr.getLastCommand())) { Completer cc; try { cc = (Completer)pr.getLastCommand().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } ParsedLine pl = new DefaultParser().new ArgumentList(line.line(), Arrays.asList(pr.getRemainingArgs()), pr.getRemainingArgs().length - 1, 0, 0, null, 0, 0); List<Candidate> ccl = new ArrayList<>(); cc.complete(reader, pl, ccl); result.addAll(ccl); } } catch (InvalidOptionException e) { } catch (IntrospectionException e) { throw new RuntimeException("Could not inspect command", e); } List<Candidate> resultList = new ArrayList<>(result); Collections.sort(resultList); candidates.addAll(resultList); }
ShellCommandCompleter implements Completer { @Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { boolean allparsed; Set<Candidate> result = new TreeSet<>(); try { Result pr = ShellCommandParser.parse(line.line(), excludedCommands); if (pr.getFirstCommand() == HelpCommand.class || pr.getFirstCommand() == ShellHelpCommand.class) { pr = ShellCommandParser.parse(pr.getRemainingArgs(), excludedCommands); } if (pr.getRemainingArgs().length > 1) { } else { OptionGroup<ID> options; if (pr.getLastCommand() == null) { options = OptionIntrospector.introspect(CSLTool.class, AdditionalShellCommands.class); } else { options = OptionIntrospector.introspect(pr.getLastCommand()); } String[] ra = pr.getRemainingArgs(); allparsed = (ra == null || ra.length == 0); for (Option<ID> o : options.getCommands()) { Class<? extends Command> cmd = OptionIntrospector.getCommand(o.getId()); if (excludedCommands.contains(cmd)) { continue; } if (allparsed || o.getLongName().startsWith(ra[0])) { result.add(new Candidate(o.getLongName())); } } } if (pr.getLastCommand() != null && Completer.class.isAssignableFrom(pr.getLastCommand())) { Completer cc; try { cc = (Completer)pr.getLastCommand().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } ParsedLine pl = new DefaultParser().new ArgumentList(line.line(), Arrays.asList(pr.getRemainingArgs()), pr.getRemainingArgs().length - 1, 0, 0, null, 0, 0); List<Candidate> ccl = new ArrayList<>(); cc.complete(reader, pl, ccl); result.addAll(ccl); } } catch (InvalidOptionException e) { } catch (IntrospectionException e) { throw new RuntimeException("Could not inspect command", e); } List<Candidate> resultList = new ArrayList<>(result); Collections.sort(resultList); candidates.addAll(resultList); } }
ShellCommandCompleter implements Completer { @Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { boolean allparsed; Set<Candidate> result = new TreeSet<>(); try { Result pr = ShellCommandParser.parse(line.line(), excludedCommands); if (pr.getFirstCommand() == HelpCommand.class || pr.getFirstCommand() == ShellHelpCommand.class) { pr = ShellCommandParser.parse(pr.getRemainingArgs(), excludedCommands); } if (pr.getRemainingArgs().length > 1) { } else { OptionGroup<ID> options; if (pr.getLastCommand() == null) { options = OptionIntrospector.introspect(CSLTool.class, AdditionalShellCommands.class); } else { options = OptionIntrospector.introspect(pr.getLastCommand()); } String[] ra = pr.getRemainingArgs(); allparsed = (ra == null || ra.length == 0); for (Option<ID> o : options.getCommands()) { Class<? extends Command> cmd = OptionIntrospector.getCommand(o.getId()); if (excludedCommands.contains(cmd)) { continue; } if (allparsed || o.getLongName().startsWith(ra[0])) { result.add(new Candidate(o.getLongName())); } } } if (pr.getLastCommand() != null && Completer.class.isAssignableFrom(pr.getLastCommand())) { Completer cc; try { cc = (Completer)pr.getLastCommand().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } ParsedLine pl = new DefaultParser().new ArgumentList(line.line(), Arrays.asList(pr.getRemainingArgs()), pr.getRemainingArgs().length - 1, 0, 0, null, 0, 0); List<Candidate> ccl = new ArrayList<>(); cc.complete(reader, pl, ccl); result.addAll(ccl); } } catch (InvalidOptionException e) { } catch (IntrospectionException e) { throw new RuntimeException("Could not inspect command", e); } List<Candidate> resultList = new ArrayList<>(result); Collections.sort(resultList); candidates.addAll(resultList); } ShellCommandCompleter();  ShellCommandCompleter(List<Class<? extends Command>> excludedCommands); }
ShellCommandCompleter implements Completer { @Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { boolean allparsed; Set<Candidate> result = new TreeSet<>(); try { Result pr = ShellCommandParser.parse(line.line(), excludedCommands); if (pr.getFirstCommand() == HelpCommand.class || pr.getFirstCommand() == ShellHelpCommand.class) { pr = ShellCommandParser.parse(pr.getRemainingArgs(), excludedCommands); } if (pr.getRemainingArgs().length > 1) { } else { OptionGroup<ID> options; if (pr.getLastCommand() == null) { options = OptionIntrospector.introspect(CSLTool.class, AdditionalShellCommands.class); } else { options = OptionIntrospector.introspect(pr.getLastCommand()); } String[] ra = pr.getRemainingArgs(); allparsed = (ra == null || ra.length == 0); for (Option<ID> o : options.getCommands()) { Class<? extends Command> cmd = OptionIntrospector.getCommand(o.getId()); if (excludedCommands.contains(cmd)) { continue; } if (allparsed || o.getLongName().startsWith(ra[0])) { result.add(new Candidate(o.getLongName())); } } } if (pr.getLastCommand() != null && Completer.class.isAssignableFrom(pr.getLastCommand())) { Completer cc; try { cc = (Completer)pr.getLastCommand().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } ParsedLine pl = new DefaultParser().new ArgumentList(line.line(), Arrays.asList(pr.getRemainingArgs()), pr.getRemainingArgs().length - 1, 0, 0, null, 0, 0); List<Candidate> ccl = new ArrayList<>(); cc.complete(reader, pl, ccl); result.addAll(ccl); } } catch (InvalidOptionException e) { } catch (IntrospectionException e) { throw new RuntimeException("Could not inspect command", e); } List<Candidate> resultList = new ArrayList<>(result); Collections.sort(resultList); candidates.addAll(resultList); } ShellCommandCompleter();  ShellCommandCompleter(List<Class<? extends Command>> excludedCommands); @Override void complete(LineReader reader, ParsedLine line, List<Candidate> candidates); }
ShellCommandCompleter implements Completer { @Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { boolean allparsed; Set<Candidate> result = new TreeSet<>(); try { Result pr = ShellCommandParser.parse(line.line(), excludedCommands); if (pr.getFirstCommand() == HelpCommand.class || pr.getFirstCommand() == ShellHelpCommand.class) { pr = ShellCommandParser.parse(pr.getRemainingArgs(), excludedCommands); } if (pr.getRemainingArgs().length > 1) { } else { OptionGroup<ID> options; if (pr.getLastCommand() == null) { options = OptionIntrospector.introspect(CSLTool.class, AdditionalShellCommands.class); } else { options = OptionIntrospector.introspect(pr.getLastCommand()); } String[] ra = pr.getRemainingArgs(); allparsed = (ra == null || ra.length == 0); for (Option<ID> o : options.getCommands()) { Class<? extends Command> cmd = OptionIntrospector.getCommand(o.getId()); if (excludedCommands.contains(cmd)) { continue; } if (allparsed || o.getLongName().startsWith(ra[0])) { result.add(new Candidate(o.getLongName())); } } } if (pr.getLastCommand() != null && Completer.class.isAssignableFrom(pr.getLastCommand())) { Completer cc; try { cc = (Completer)pr.getLastCommand().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } ParsedLine pl = new DefaultParser().new ArgumentList(line.line(), Arrays.asList(pr.getRemainingArgs()), pr.getRemainingArgs().length - 1, 0, 0, null, 0, 0); List<Candidate> ccl = new ArrayList<>(); cc.complete(reader, pl, ccl); result.addAll(ccl); } } catch (InvalidOptionException e) { } catch (IntrospectionException e) { throw new RuntimeException("Could not inspect command", e); } List<Candidate> resultList = new ArrayList<>(result); Collections.sort(resultList); candidates.addAll(resultList); } ShellCommandCompleter();  ShellCommandCompleter(List<Class<? extends Command>> excludedCommands); @Override void complete(LineReader reader, ParsedLine line, List<Candidate> candidates);  }