@Override
public void execute() throws NameNotFoundException, IsolateStartupException, ShellException {
final PrintWriter out = getOutput().getPrintWriter();
final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();
boolean listConsoles = FLAG_LIST.isSet();
boolean newConsole = FLAG_NEW.isSet();
boolean isolateNewConsole = FLAG_ISOLATED.isSet();
boolean test = FLAG_TEST.isSet();
if (listConsoles) {
conMgr.printConsoles(out);
} else if (newConsole) {
if (isolateNewConsole) {
try {
Isolate newIsolate = new Isolate(
ConsoleCommand.IsolatedConsole.class.getName(),
new String[0]);
newIsolate.start();
out.println("Started new isolated console");
} catch (IsolateStartupException ex) {
out.println("Failed to start new isolated console");
throw ex;
}
} else {
createConsoleWithShell(conMgr, out);
}
} else if (test) {
out.println("test RawTextConsole");
final TextConsole console = (TextConsole) conMgr.createConsole(
null, ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.NO_LINE_EDITTING);
conMgr.registerConsole(console);
conMgr.focus(console);
console.clear();
}
}