}
};
exampleConsole.addCompletion(completer);
final ConsoleCallback consoleCallback = new AeshConsoleCallback() {
@Override
public int execute(ConsoleOperation output) throws InterruptedException {
try {
//To change body of implemented methods use File | Settings | File Templates.
exampleConsole.getShell().out().println("======>\"" + output.getBuffer());
if(masking) {
exampleConsole.getShell().out().print("got password: " + output.getBuffer() + ", stopping masking");
masking = false;
exampleConsole.setPrompt(prompt);
}
else if (output.getBuffer().equalsIgnoreCase("quit") || output.getBuffer().equalsIgnoreCase("exit") ||
output.getBuffer().equalsIgnoreCase("reset")) {
exampleConsole.stop();
}
else if(output.getBuffer().equalsIgnoreCase("password")) {
masking = true;
exampleConsole.setPrompt(new Prompt("password: ", (char) 0));
}
else if(output.getBuffer().startsWith("blah")) {
exampleConsole.getShell().err().println("blah. command not found.");
exampleConsole.getShell().out().print("BAH" + Config.getLineSeparator());
}
else if(output.getBuffer().equals("clear"))
exampleConsole.clear();
else if(output.getBuffer().startsWith("man")) {
//exampleConsole.attachProcess(test);
//man = new ExampleConsoleCommand(exampleConsole, output);
exampleConsole.getShell().out().println("trying to wait for input");
CommandOperation co = null;
try {
co = getInput();
}
catch (InterruptedException e) {
e.printStackTrace();
return -1;
}
exampleConsole.getShell().out().println("got: " + co.toString());
//exampleConsole.attachProcess(test);
}
else if(output.getBuffer().startsWith("login")) {
exampleConsole.setConsoleCallback(passwordCallback);
exampleConsole.setPrompt(new Prompt("Username: "));
}
return 0;
}
catch (IOException ioe) {
exampleConsole.getShell().out().println("Exception: "+ioe.getMessage());
return -1;
}
}
};
exampleConsole.setConsoleCallback(consoleCallback);
exampleConsole.start();
exampleConsole.setPrompt(prompt);
passwordCallback = new AeshConsoleCallback() {
private boolean hasUsername = false;
@Override
public int execute(ConsoleOperation output) throws InterruptedException {
if(hasUsername) {