MCPcopy Create free account
hub / github.com/dynjs/dynjs / run

Method run

src/main/java/org/dynjs/cli/Repl.java:70–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 }
69
70 public void run() {
71 final Settings consoleSettings = new SettingsBuilder()
72 .outputStream(this.out)
73 .inputStream(this.in)
74 .historySize(100)
75 .parseOperators(false)
76 .quitHandler(new QuitHandler() {
77 @Override
78 public void quit() {
79 if (log != null) {
80 log.close();
81 }
82 }
83 }).create();
84
85 final Console console = new Console(consoleSettings);
86 console.getShell().out().println(welcome);
87 console.setPrompt(new Prompt(prompt));
88 console.setConsoleCallback(new AeshConsoleCallback() {
89 @Override
90 public int execute(ConsoleOperation output) {
91 String statement = output.getBuffer();
92 log.write(statement + "\n");
93 if (statement.equalsIgnoreCase("exit")) {
94 console.stop();
95 return 0;
96 } else {
97 try {
98 Object object = runtime.evaluate(statement);
99 log.write(object.toString() + "\n");
100 console.getShell().out().println(object.toString());
101 } catch (DynJSException e) {
102 console.getShell().out().println(e.getLocalizedMessage());
103 logException(e);
104 } catch (IncompatibleClassChangeError e) {
105 console.getShell().err().println("ERROR> " + e.getLocalizedMessage());
106 console.getShell().err().println("Error parsing statement: " + statement);
107 logException(e);
108 } catch (Exception e) {
109 e.printStackTrace(new PrintWriter(out));
110 logException(e);
111 }
112 }
113 return 0;
114 }
115 });
116 console.start();
117 }
118
119 private void logException(Throwable e) {
120 log.write(e.getLocalizedMessage() + "\n");

Callers 1

startReplMethod · 0.95

Calls 2

createMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected