4646
4747import org .scijava .Context ;
4848import org .scijava .Gateway ;
49- import org .scijava .log .LogService ;
5049import org .scijava .plugin .Parameter ;
5150import org .scijava .plugin .PluginInfo ;
5251import org .scijava .plugin .PluginService ;
@@ -70,9 +69,6 @@ public class ScriptREPL {
7069 @ Parameter (required = false )
7170 private PluginService pluginService ;
7271
73- @ Parameter (required = false )
74- private LogService log ;
75-
7672 private final PrintStream out ;
7773
7874 /** List of interpreter-friendly script languages. */
@@ -81,6 +77,9 @@ public class ScriptREPL {
8177 /** The currently active interpreter. */
8278 private ScriptInterpreter interpreter ;
8379
80+ /** Flag for debug mode. */
81+ private boolean debug ;
82+
8483 public ScriptREPL (final Context context ) {
8584 this (context , System .out );
8685 }
@@ -172,6 +171,7 @@ public boolean evaluate(final String line) {
172171 if (tLine .equals (":help" )) help ();
173172 else if (tLine .equals (":vars" )) vars ();
174173 else if (tLine .equals (":langs" )) langs ();
174+ else if (tLine .equals (":debug" )) debug ();
175175 else if (tLine .startsWith (":lang " )) lang (line .substring (6 ).trim ());
176176 else if (tLine .equals (":quit" )) return false ;
177177 else {
@@ -188,7 +188,7 @@ public boolean evaluate(final String line) {
188188 catch (final ScriptException exc ) {
189189 // NB: Something went wrong interpreting the line of code.
190190 // Let's just display the error message, unless we are in debug mode.
191- if (log . isDebug () ) exc .printStackTrace (out );
191+ if (debug ) exc .printStackTrace (out );
192192 else {
193193 final String msg = exc .getMessage ();
194194 out .println (msg == null ? exc .getClass ().getName () : msg );
@@ -211,6 +211,7 @@ public void help() {
211211 out .println (" :vars | dump a list of variables" );
212212 out .println (" :lang <name> | switch the active language" );
213213 out .println (" :langs | list available languages" );
214+ out .println (" :debug | toggle full stack traces" );
214215 out .println (" :quit | exit the REPL" );
215216 out .println ();
216217 out .println ("Or type a statement to evaluate it with the active language." );
@@ -269,6 +270,11 @@ public void langs() {
269270 printColumns (names , versions , aliases );
270271 }
271272
273+ public void debug () {
274+ debug = !debug ;
275+ out .println ("debug mode -> " + debug );
276+ }
277+
272278 // -- Main method --
273279
274280 public static void main (final String ... args ) throws Exception {
0 commit comments