Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable REPL power user mode (:power) from script

I am trying to dynamically interpret a string as a command in Scala. For this, from what I understand, I need to call intp.interpret("string") (where intp stands for the current interpreter and string for my command) while being in power mode, right?

However, my problem is that I want to do that from inside a script. Thus, I am looking for a way to switch to power user mode from inside a script, and then call intp.interpret.

Is there any way to do this switching from inside a script file?

like image 851
Y.K. Avatar asked Sep 23 '12 11:09

Y.K.


1 Answers

If you're invoking the REPL from a bash script or somesuch then you can enable :power mode immediately via the scala.repl.power system property,

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>
like image 144
Miles Sabin Avatar answered Sep 26 '22 15:09

Miles Sabin