}
};
exampleConsole.addCompletion(completer);
final ConsoleCallback consoleCallback = new ConsoleCallback() {
@Override
public int readConsoleOutput(ConsoleOperation output) {
try {
//To change body of implemented methods use File | Settings | File Templates.
exampleConsole.getShell().out().print("======>\"" + output.getBuffer() + "\"\n");
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().print("blah. command not found.\n");
exampleConsole.getShell().out().print("BAH" + Config.getLineSeparator());
}
else if(output.getBuffer().equals("clear"))
exampleConsole.clear();
else if(output.getBuffer().startsWith("man")) {
//exampleConsole.attachProcess(test);
ConsoleCommand test =
new ExampleConsoleCommand(exampleConsole, output);
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 ConsoleCallback() {
private boolean hasUsername = false;
@Override
public int readConsoleOutput(ConsoleOperation output) {
if(hasUsername) {