/** * If the command is being completed from anywhere at or after the given argument index, * generate suggestions for the entire command from that index, based on the given choices. */ public void suggestJoinedArguments(int start, Iterable<String> choices) throws SuggestException { final SuggestionContext ctx = getSuggestionContext(); if(ctx != null && ctx.isArgument()) { if(start == ctx.getIndex()) { ctx.suggestArgument(start, choices); } else if(start < ctx.getIndex()) { final String prefix = String.join(" ", parsedArgs.subList(start, ctx.getIndex())).toLowerCase() + " "; final List<String> filtered = new ArrayList<>(); for(String choice : choices) { if(choice.toLowerCase().startsWith(prefix)) { filtered.add(choice.substring(prefix.length())); } } ctx.suggestArgument(ctx.getIndex(), filtered); } } }
/** * If the given argument is being completed, generate suggestions based on the given choices. */ public void suggestArgument(int index, Iterable<String> choices) throws SuggestException { if(isSuggesting() && getSuggestionContext().isArgument()) { getSuggestionContext().suggestArgument(index, choices); } }