private void writeLine(String out) { console.getShell().out().println(out); }
executor = createExecutor(commandLine, console, props, autoCompleter); loadVariables(commandLine, executor); console.setPrompt(new Prompt(EXPRESSION_PROMPT)); console.addCompletion(this); console.setConsoleCallback(this);
/** * Quits the console. */ private void handleQuit() { try { console.stop(); StellarFunctions.close(); } catch (Throwable e) { e.printStackTrace(); } }
final Console console = new Console(consoleSettings); console.getShell().out().println(welcome); console.setPrompt(new Prompt(prompt)); console.setConsoleCallback(new AeshConsoleCallback() { @Override public int execute(ConsoleOperation output) { console.start();
@Override public void handleInterrupt(Console console, Action action) { if (action == Action.INTERRUPT) { console.getShell().out().println("^C"); console.clearBufferAndDisplayPrompt(); } else { console.stop(); console.currentProcessFinished(null); } } });
@Override public int execute(ConsoleOperation output) { String statement = output.getBuffer(); log.write(statement + "\n"); if (statement.equalsIgnoreCase("exit")) { console.stop(); return 0; } else { try { Object object = runtime.evaluate(statement); log.write(object.toString() + "\n"); console.getShell().out().println(object.toString()); } catch (DynJSException e) { console.getShell().out().println(e.getLocalizedMessage()); logException(e); } catch (IncompatibleClassChangeError e) { console.getShell().err().println("ERROR> " + e.getLocalizedMessage()); console.getShell().err().println("Error parsing statement: " + statement); logException(e); } catch (Exception e) { e.printStackTrace(new PrintWriter(out)); logException(e); } } return 0; } });
console.getShell().out().println("^C"); console.clearBufferAndDisplayPrompt(); console.getShell().out().println("Use \"exit\" to leave the shell."); console.clearBufferAndDisplayPrompt(); console.getShell().out().println(); exitCommand.getParser().getCommand().execute( new AeshCommandInvocation((AeshConsoleImpl) ShellImpl.this.console, ControlOperator.NONE, 1,
public static void enhance(AeshConsoleImpl console) { try { Globals.stdin.setConsole(console); Field field = AeshConsoleImpl.class.getDeclaredField("console"); field.setAccessible(true); Console internalConsole = (Console) field.get(console); internalConsole.setConsoleCallback(new AeshConsoleCallbackImpl(console)); } catch (Exception e) { throw new RuntimeException("Failed to install Aesh enhancement", e); } } }
/** * Handles the main loop for the REPL. */ public void run() { // welcome message writeLine(WELCOME); // print the globals if we got 'em executor.getContext() .getCapability(GLOBAL_CONFIG, false) .ifPresent(conf -> writeLine(conf.toString())); console.start(); }
/** * Creates the REPL's console. * @param commandLine The command line options. */ private Console createConsole(CommandLine commandLine) { // console settings boolean useAnsi = !commandLine.hasOption("na"); SettingsBuilder settings = new SettingsBuilder().enableAlias(true) .enableMan(true) .ansi(useAnsi) .parseOperators(false) .inputStream(PausableInput.INSTANCE); if(commandLine.hasOption("irc")) { settings = settings.inputrc(new File(commandLine.getOptionValue("irc"))); } return new Console(settings.create()); }
public static void enhance(AeshConsoleImpl console) { try { Globals.stdin.setConsole(console); Field field = AeshConsoleImpl.class.getDeclaredField("console"); field.setAccessible(true); Console internalConsole = (Console) field.get(console); internalConsole.setConsoleCallback(new AeshConsoleCallbackImpl(console)); } catch (Exception e) { throw new RuntimeException("Failed to install Aesh enhancement", e); } } }