File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/main/java/net/marcellperger/mathexpr/interactive Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 88import org .jetbrains .annotations .Nullable ;
99
1010import java .io .PrintStream ;
11+ import java .util .NoSuchElementException ;
1112
1213public class Shell {
1314 Input in ;
@@ -22,15 +23,22 @@ public static void main(String[] args) {
2223 new Shell ().run ();
2324 }
2425
25- // TODO run() until exit better - parse exit command/Ctrl+C
26+ // TODO run() until exit better - parse exit command, more robust/extensible command handling system
2627
2728 public void run () {
28- //noinspection InfiniteLoopStatement
29- while (true ) getAndRunCommand ();
29+ //noinspection StatementWithEmptyBody
30+ while (getAndRunCommand ()) {}
3031 }
3132
32- public void getAndRunCommand () {
33- runCommand (in .getInput (">? " ));
33+ public /*returns wantMore */ boolean getAndRunCommand () {
34+ String inp ;
35+ try {
36+ inp = in .getInput (">? " );
37+ } catch (NoSuchElementException e ) {
38+ return false ;
39+ }
40+ runCommand (inp );
41+ return true ;
3442 }
3543 public void runCommand (String cmd ) {
3644 @ Nullable MathSymbol sym = parseCmdOrPrintError (cmd );
You can’t perform that action at this time.
0 commit comments