alexarchambault on 1.6.3
alexarchambault on master
1.6.3 (compare)
lihaoyi on gh-pages
5ad9ae5538f23cab92ccd8c6b1617d8… (compare)
alexarchambault on master
Partly revert 84d48542 (#923) … (compare)
Ammonite-Shell/Scripting
chapter in documentation I understand that this usecase is supported. One of essentials here is an ability to invoke system binaries. I see we have this ability throuhg %
, %%
commands. I have installed ammonite per instructions on ammonite.io
. In this setup percent commands are available only when amm is run interactivly. This is because predef code with necessary imports is pre-executed only for interactive sessions. Should I solve this by importing predef file by hand in all my future scripts? Or is this a bad idea for some reason. If on the other hand it is a good idea why predef is not pre-executed when scripts are run non-interactively as well? Or is there another .ammonite file which is run before scripts like this? I hope you see my confusion. And thanks for ammonite!
import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`
interp.configureCompiler(_.settings.YpartialUnification.value = true)
interp.configureCompiler(_.settings.Ydelambdafy.tryToSetColon(List("inline")))
object load {
def fs2Version(version: String) = {
repl.load.apply(s"""
import $$ivy.`co.fs2::fs2-io:$version`, fs2._, fs2.concurrent._, cats._, cats.implicits._, cats.effect._, cats.effect.implicits._, scala.concurrent.duration._
implicit val ioContextShift: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.Implicits.global)
implicit val ioTimer: Timer[IO] = IO.timer(scala.concurrent.ExecutionContext.Implicits.global)
""")
if (!version.startsWith("1")) repl.load.apply("""
val globalBlocker: Blocker = cats.effect.Blocker.liftExecutionContext(scala.concurrent.ExecutionContext.Implicits.global)
""")
}
def fs2 = fs2Version("2.0.1")
}
println("Enter encrypted data:")
val encryptedDataStr = scala.io.StdIn.readLine()
Hi everyone, can someone explain to me the behavior depicted in this screenshot?
I am saving a repl session and then import a script file which just contains a dummy function called test
that simply prints "hi ho". Then I load the previously saved repl session again and import the file again but it cannot find the test
function. Am I just not understanding something about file imports or is this strange behavior?
import $fs2.blahblahblah
instead of calling a magic function, but that's not really any better. Just a different spelling in the end
ls.rec.iter!
as mentioned in the docs (I'm using amm-1.8.1 in scala 2.12.10) and it doesn't seem to exist. I've tried ever other thing I can think of. If this doesn't exist, is there a good replacement, or advice on the best way to use ammonite.ops to do a ls.rec
on a huge tree in a "streaming" fashion?
Hi all, I'm working to embed Ammonite in my application, and I'd like to be able to pass an object from the application to the Ammonite environment, e.g.
def my_entrypoint(foo: Foo) = {
// Make `foo` accessible from the script.
ammonite.Main(...).runScript(...)
}
I see the run
method on Main
would allow me to do this, but I want to be able to do this when running a script non-interactively - are there any methods that would allow me to achieve this?
I managed to get it working without a threadlocal with this:
ammoniteMain
.instantiateRepl(IndexedSeq("foo" -> foo)).map { repl =>
repl.interp.initializePredef()
ammonite.main.Scripts.runScript(...)
}
The only issue is that it doesn't seem to pick up the @main
annotations.
@ import scala.collection.JavaConverters.asScalaBufferConverter
import scala.collection.JavaConverters.asScalaBufferConverter
@ val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor)
cmd44.sc:1: type mismatch;
found : java.util.List[String]
required: scala.collection.mutable.Buffer[String]
val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor)
^
Compilation Failed
@