Enable user mode REPL (: power) from script

I am trying to dynamically interpret a string as a command in Scala. To do this, based on what I understand, I need to call intp.interpret("string")(where intpdoes the current interpreter mean stringfor my command) while in power mode, right?

However, my problem is that I want to do this from within the script. So I'm looking for a way to switch to user power mode from within the script, and then call intp.interpret.

Is there a way to do this switch from inside the script file?

+5
source share
1 answer

REPL bash script somesuch, :power scala.repl.power,

miles@lewis$ scala -Dscala.repl.power
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05)
Type in expressions to have them evaluated.
Type :help for more information.

scala>
[info] compiler init time: 2.186 s.

scala>
** Power User mode enabled - BEEP BOOP SPIZ **
** :phase has been set to 'typer'.          **
** scala.tools.nsc._ has been imported      **
** global._ and definitions._ also imported **
** Try  :help,  vals.<tab>,  power.<tab>    **

scala> 
[info] total init time: 5.105 s.

scala>
+1

All Articles