Zond: команды выхода
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
group = 'asys'
|
||||
version = '0.7.1-SNAPSHOT'
|
||||
version = '0.7.2-SNAPSHOT'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
25
zond/src/main/java/asys/zond/ZondCommandHandler.java
Normal file
25
zond/src/main/java/asys/zond/ZondCommandHandler.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,8 @@ public class Shell {
|
||||
public void setOutputHook(ShellOutputHook outputHook) {
|
||||
shellStdOut.setOutputHook(outputHook);
|
||||
}
|
||||
|
||||
public void setCommandHandler(CommandHandler commandHandler) {
|
||||
this.commandHandler = commandHandler;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user