Save Ammonite (Scala REPL) History to File

综合编程 2017-04-08

I use Ammonite
and ipython
like REPL for Scala.

I find it handy to save history to file, so here is how to do it in Ammonite.

importjava.io.BufferedWriter
importjava.io.FileWriter
valfile = new File("some-file.scala")
valbw = new BufferedWriter(new FileWriter(file))
valhistory = repl.history.mkString("n")
bw.write(history)
bw.close()
 

Ammonite exposes a global object called repl
, which has a method called history
. The code above converts history to a new line separated string and writes it to file.

Enjoy ��

Alex Kras

责编内容by:Alex Kras (源链)。感谢您的支持!

您可能感兴趣的

Introducing Accessible Scala Thursday 14 June 2018 Guillaume Massé Scala is proudly a w...
Pass the map containing the user-defined object as... I am using play framework v2.2 and trying to pass a map to a scala template. ...
Finatra : Building Rest APIs Made Simple Finatra is an open-source project by Twitter that can be used to build REST ...
WD-40 oils sales and finance processes in Europe w... The sales and marketing firm – which makes the WD-40 concentrate but is not ...
How I came to write the Scala Cookbook The funny thing about writing the Scala Cookbook is that it started as a whi...