Archived
0

Zond: команды выхода

This commit is contained in:
2017-06-15 15:42:55 +03:00
parent d8d80cf6dc
commit 6fa8b4ecc4
4 changed files with 31 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
group = 'asys'
version = '0.7.1-SNAPSHOT'
version = '0.7.2-SNAPSHOT'
apply plugin: 'application'

View File

@@ -17,6 +17,7 @@ public class Main {
private void start() {
Shell shell = Shell.getInstance();
try {
shell.setCommandHandler(new ZondCommandHandler());
shell.start(System.in);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -0,0 +1,25 @@
/*
* DmitriyMX <d.mihailov@samson-rus.com>
* 2017-06-15
*/
package asys.zond;
import asys.zond.shell.CommandHandler;
import asys.zond.shell.Shell;
public class ZondCommandHandler implements CommandHandler {
@Override
public void handle(String commandLine) {
if (commandLine.startsWith(":")) {
internalCommand(commandLine.substring(1));
} else {
Shell.getInstance().getOutput().println(commandLine);
}
}
private void internalCommand(String line) {
if (line.equalsIgnoreCase("exit") || line.equalsIgnoreCase("quit")) {
Shell.getInstance().shutdown();
}
}
}

View File

@@ -59,4 +59,8 @@ public class Shell {
public void setOutputHook(ShellOutputHook outputHook) {
shellStdOut.setOutputHook(outputHook);
}
public void setCommandHandler(CommandHandler commandHandler) {
this.commandHandler = commandHandler;
}
}