/** * Executes line. * * @return false if the users has issued an "exit" command, true otherwise */ protected boolean execute(String line) throws Exception { try { runCommand(line); } catch (ExitException e) { return false; } catch (CommandException e) { console.print(e.getMessage() + System.getProperty("line.separator")); } return true; }
@Override public void start(Application app) throws IOException { super.start(app); updatePrompt(); // register completors console.addCompleter(new CompositeCompletor(this, app.getCommandRegistry())); String line = console.readLine(); while (line != null) { line = line.trim(); try { if (line.length() > 0) { if (!execute(line)) { break; } // println(); } } catch (Exception e) { e.printStackTrace(); } line = console.readLine(); } console.print("Bye"); console.println(); }