ash-java/src/main/java/org/eiichiro/ash/CommandCompleter.java
@Override
	public int complete(String buffer, int cursor, List<CharSequence> candidates) {
		SortedSet<String> commands = new TreeSet<>(shell.commands().keySet());
		
		if (buffer == null) {
			candidates.addAll(commands);
		} else {
			for (String match : commands.tailSet(buffer)) {
				if (!match.startsWith(buffer)) {
					break;
				}
				
				candidates.add(match);
			}
		}
		
		if (candidates.size() == 1) {
			candidates.set(0, candidates.get(0) + " ");
		}
		
		return candidates.isEmpty() ? -1 : 0;
	}
@Override
	public int complete(String buffer, int cursor, List<CharSequence> candidates) {
		SortedSet<String> commands = new TreeSet<>(shell.commands().keySet());
		
		if (buffer == null) {
			candidates.addAll(commands);
		} else {
			for (String match : commands.tailSet(buffer)) {
				if (!match.startsWith(buffer)) {
					break;
				}
				
				candidates.add(match);
			}
		}
		
		if (candidates.size() == 1) {
			candidates.set(0, candidates.get(0) + " ");
		}
		
		return candidates.isEmpty() ? -1 : 0;
	}
/* (non-Javadoc)
@see jline.console.completer.Completer#complete(java.lang.String, int, java.util.List)