@@ -43,6 +43,12 @@ public class CompletionProposal {
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* Whether the proposal should bypass escaping and quoting rules. This is useful for command proposals, which can
|
||||
* appear as true multi-word Strings.
|
||||
*/
|
||||
private boolean dontQuote = false;
|
||||
|
||||
public CompletionProposal(String value) {
|
||||
this.value = this.displayText = value;
|
||||
}
|
||||
@@ -83,6 +89,15 @@ public class CompletionProposal {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompletionProposal dontQuote(boolean dontQuote) {
|
||||
this.dontQuote = dontQuote;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean dontQuote() {
|
||||
return dontQuote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
|
||||
@@ -172,6 +172,7 @@ public class Shell implements CommandRegistry {
|
||||
|
||||
private CompletionProposal toCompletionProposal(String command, MethodTarget methodTarget) {
|
||||
return new CompletionProposal(command)
|
||||
.dontQuote(true)
|
||||
.category("Available commands")
|
||||
.description(methodTarget.getHelp());
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class JLineShell {
|
||||
List<CompletionProposal> proposals = shell.complete(context);
|
||||
proposals.stream()
|
||||
.map(p -> new Candidate(
|
||||
cpl.emit(p.value()).toString(),
|
||||
p.dontQuote() ? p.value() : cpl.emit(p.value()).toString(),
|
||||
p.displayText(),
|
||||
p.category(),
|
||||
p.description(),
|
||||
|
||||
Reference in New Issue
Block a user