repl: help command

This commit is contained in:
Stepan Koltsov
2012-06-09 23:25:39 +04:00
parent 8a72e22487
commit b99f7c5505
@@ -85,7 +85,8 @@ public class ReplFromTerminal {
private void doRun() {
try {
System.out.println("Kotlin");
System.out.println("Kotlin interactive shell");
System.out.println("Type :help for help");
while (true) {
boolean next = one();
if (!next) {
@@ -109,6 +110,11 @@ public class ReplFromTerminal {
if (line == null) {
return false;
}
if (line.startsWith(":")) {
return oneCommand(line.substring(1));
}
Object value = getReplInterpreter().eval(line);
System.out.println(value);
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) {
new ReplFromTerminal(disposable, compilerDependencies).doRun();
}