use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.
the class CliCompletionTestCase method complete.
// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
completer.complete(op);
if (separator != null) {
assertEquals(op.hasAppendSeparator(), separator);
}
List<String> candidates = new ArrayList<>();
for (TerminalString ts : op.getCompletionCandidates()) {
candidates.add(ts.getCharacters());
}
// aesh-readline does sort the candidates prior to display.
Collections.sort(candidates);
return candidates;
}
use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.
the class CLICompletionHandler method complete.
@Override
public void complete(AeshCompleteOperation co) {
LOG.debugf("Completing {0}", co.getBuffer());
cliCompleter.complete(ctx, co, this);
if (ctx.isColorOutput()) {
List<TerminalString> completionCandidates = co.getCompletionCandidates();
List<TerminalString> requiredCandidates = new ArrayList<>();
for (TerminalString candidate : completionCandidates) {
if (candidate.toString().endsWith("*") && !"*".equals(candidate.toString())) {
TerminalString newCandidate = Util.formatRequired(candidate);
requiredCandidates.add(newCandidate);
}
}
completionCandidates.removeIf(new Predicate<TerminalString>() {
@Override
public boolean test(TerminalString candidate) {
return candidate.toString().endsWith("*");
}
});
completionCandidates.addAll(requiredCandidates);
}
LOG.debugf("Completion candidates {0}", co.getCompletionCandidates());
}
use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly-core by wildfly.
the class CliCompletionTestCase method complete.
// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator, int offset) {
Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
completer.complete(op);
if (separator != null) {
assertEquals(op.hasAppendSeparator(), separator);
}
if (offset > 0) {
assertEquals(op.getOffset(), offset);
}
List<String> candidates = new ArrayList<>();
for (TerminalString ts : op.getCompletionCandidates()) {
candidates.add(ts.getCharacters());
}
return candidates;
}
use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly by wildfly.
the class SecurityCommandsTestCase method complete.
// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
completer.complete(op);
if (separator != null) {
assertEquals(op.hasAppendSeparator(), separator);
}
List<String> candidates = new ArrayList<>();
for (TerminalString ts : op.getCompletionCandidates()) {
candidates.add(ts.getCharacters());
}
// aesh-readline does sort the candidates prior to display.
Collections.sort(candidates);
return candidates;
}
use of org.aesh.readline.terminal.formatting.TerminalString in project wildfly by wildfly.
the class SecurityAuthCommandsTestCase method complete.
// This completion is what aesh-readline completion is calling, so more
// similar to interactive CLI session
private List<String> complete(CommandContext ctx, String cmd, Boolean separator) {
Completion<AeshCompleteOperation> completer = (Completion<AeshCompleteOperation>) ctx.getDefaultCommandCompleter();
AeshCompleteOperation op = new AeshCompleteOperation(cmd, cmd.length());
completer.complete(op);
if (separator != null) {
assertEquals(op.hasAppendSeparator(), separator);
}
List<String> candidates = new ArrayList<>();
for (TerminalString ts : op.getCompletionCandidates()) {
candidates.add(ts.getCharacters());
}
// aesh-readline does sort the candidates prior to display.
Collections.sort(candidates);
return candidates;
}
Aggregations