repl: help command
This commit is contained in:
@@ -85,7 +85,8 @@ public class ReplFromTerminal {
|
|||||||
|
|
||||||
private void doRun() {
|
private void doRun() {
|
||||||
try {
|
try {
|
||||||
System.out.println("Kotlin");
|
System.out.println("Kotlin interactive shell");
|
||||||
|
System.out.println("Type :help for help");
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean next = one();
|
boolean next = one();
|
||||||
if (!next) {
|
if (!next) {
|
||||||
@@ -109,6 +110,11 @@ public class ReplFromTerminal {
|
|||||||
if (line == null) {
|
if (line == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.startsWith(":")) {
|
||||||
|
return oneCommand(line.substring(1));
|
||||||
|
}
|
||||||
|
|
||||||
Object value = getReplInterpreter().eval(line);
|
Object value = getReplInterpreter().eval(line);
|
||||||
System.out.println(value);
|
System.out.println(value);
|
||||||
return true;
|
return true;
|
||||||
@@ -118,6 +124,20 @@ public class ReplFromTerminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean oneCommand(@NotNull String command) {
|
||||||
|
if (command.equals("help")) {
|
||||||
|
System.out.println("This is Kotlin REPL help");
|
||||||
|
System.out.println("Available commands are:");
|
||||||
|
System.out.println(":help show this help");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Unknown command");
|
||||||
|
System.out.println("Type :help for help");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void run(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies) {
|
public static void run(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies) {
|
||||||
new ReplFromTerminal(disposable, compilerDependencies).doRun();
|
new ReplFromTerminal(disposable, compilerDependencies).doRun();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user