Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 30 2019 14:37
    bhaskarmelkani starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 28 2019 15:07
    ishubelko starred lihaoyi/Ammonite
  • Jan 25 2019 22:38
    borissmidt starred lihaoyi/Ammonite
  • Jan 25 2019 17:12

    alexarchambault on 1.6.3

    (compare)

  • Jan 25 2019 17:11

    alexarchambault on master

    1.6.3 (compare)

  • Jan 25 2019 15:48
    alexarchambault commented #923
  • Jan 25 2019 01:15

    lihaoyi on gh-pages

    5ad9ae5538f23cab92ccd8c6b1617d8… (compare)

  • Jan 25 2019 00:50

    alexarchambault on master

    Partly revert 84d48542 (#923) … (compare)

  • Jan 25 2019 00:50
    alexarchambault closed #923
  • Jan 25 2019 00:50
    alexarchambault closed #920
  • Jan 25 2019 00:50
    alexarchambault closed #922
  • Jan 24 2019 23:13
    lihaoyi commented #923
  • Jan 24 2019 22:39
    alexarchambault closed #921
  • Jan 24 2019 22:39
    alexarchambault commented #921
  • Jan 24 2019 22:39
    alexarchambault edited #923
  • Jan 24 2019 22:38
    alexarchambault opened #923
  • Jan 24 2019 22:37
    david-bouyssie commented #919
  • Jan 24 2019 21:33
    nksureshkumar commented #922
Sören Brunk
@sbrunk
@phrmoy yes, on Spark master this is included by default, but it seems it's not part of 2.4. See https://github.com/apache/spark/pull/23607/files#diff-28a2ffae3ceff1bd5646567163c3a00b
phrmoy
@phrmoy
Well, it's great to know that this will be included in Spark at some point. Thanks for sharing.
Li Haoyi
@lihaoyi
@/all Ammonite 1.8.0 is out http://ammonite.io/#1.8.0, with an OS-Lib upgrade
Diego E. Alonso Blas
@diesalbla
Good morning.
Is there a way of run an ammonite console in sbt, as an alternative to sbt console, that will load the files in the project?
I have tried writing a Main as suggested in https://ammonite.io/#Debugging, and running it with the run command inside sbt , but that did not work...
Emmanuel Nhan
@enhan

@diesalbla Use this :

libraryDependencies += {
  val version = scalaBinaryVersion.value match {
    case "2.10" => "1.0.3"
    case _ ⇒ "1.8.0"
  }
  "com.lihaoyi" % "ammonite" % version % "test" cross CrossVersion.full
}

sourceGenerators in Test += Def.task {
  val file = (sourceManaged in Test).value / "amm.scala"
  IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
  Seq(file)
}.taskValue

and if you want, add a shortcut :
addCommandAlias("repl", "test:runMain amm")

Diego E. Alonso Blas
@diesalbla
:eyeglasses:
Emmanuel Nhan
@enhan
@diesalbla by the way, it is in https://ammonite.io/#Ammonite-REPL section of the doc. Not under the "debugging" one.
Diego E. Alonso Blas
@diesalbla
@enhan Do you have an example of some project with the full SBT configured? I am afraid it is still failing me...
nderraugh-yw
@nderraugh-yw

Anyone familiar with importing from a secure private bintray? I've tried to follow various snippets I've found through Google, but can't make it go.

import coursier.core.Authentication, coursier.MavenRepository

interp.repositories() ++= Seq(MavenRepository(
      "https://some.bintray.com/maven"
      authentication = Some(Authentication("user", "pass"))
    ))

import $ivy.{
  `com.some:artifact_2.12:1.0.9-85`
}

gives me

Failed to resolve ivy dependencies:Error downloading com.some:artifact_2.12:1.0.9-85
  not found: /Users/nderraugh/.ivy2/local/com.some/artifact_2.12/1.0.9-85/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/com/some/artifact_2.12/1.0.9-85/artifact_2.12-1.0.9-85.pom
Dmitriy Kuzkin
@kuzkdmy
image.png

HI, may be somebody can assist

I have to call
git blame <file> | grep -n '^0{8} ' | cut -f1 -d:
This gives me line numbers of changed git files

https://stackoverflow.com/questions/8259851/using-git-diff-how-can-i-get-added-and-modified-lines-numbers/12179492

Can I somehow to execut this as a native command, it just hungs

image.png
Dmitriy Kuzkin
@kuzkdmy
image.png
Jakub Dubovsky
@james64
Hey all! I am looking into ways how to replace bash by ammonite for writing general non-interactive scripts. From existance of 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!
Michael Pilquist
@mpilquist
I know how to import libraries from an ammonite predef. How can I write a function/alias in an ammonite predef that imports libraries when function is run?
Michael Pilquist
@mpilquist
Oh, repl.load.exec
Michael Pilquist
@mpilquist
In case this is helpful to anyone else, here’s what I came up with:
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")
}
Chris Stewart
@Christewart
Does ammonite support reading from stdin using scala.io.StdIn.readLine()? I can't seem to terminate the input by hitting the "enter" key
Basically something simple like this println("Enter encrypted data:") val encryptedDataStr = scala.io.StdIn.readLine()
Chris Stewart
@Christewart
This is being run from bloop, if that matters
Max
@maxstreese

Hi everyone, can someone explain to me the behavior depicted in this screenshot?

image.png

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?

Li Haoyi
@lihaoyi
@mpilquist sorry I didn't see this, yeah that looks like about as good as you are going to get. If you want to do magicky things like change the set of things in local scope by calling a function, the eval-ish functions like repl.load.apply are how you do that
you could also write your own custom import hook, to do import $fs2.blahblahblah instead of calling a magic function, but that's not really any better. Just a different spelling in the end
christobill
@christobill
Hey there! About ammonite in intellij support. It works well with dependencies but not with transitive dependencies. Has anyone solve this problem?
Tom Green
@tmgreen
Hi I'm trying to use 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?
Li Haoyi
@lihaoyi
docs are out of date, try os.walk.stream
Max
@maxstreese
@maxstreese is this question too dummy @lihaoyi ? This not working as suggested in the docs makes me wonder how to itereate and play with a script in a different way
Tom Green
@tmgreen
@lihaoyi Thanks! I'll try that. Thanks again for a great tool!
christobill
@christobill
Following my question of before. Would it possible to share a common dependency list between ammonite and sbt? After all it’s just a matter of transfoming “ and % in : . Then intellij through to the build.sbt can provide full support for .sc scripts?
Li Haoyi
@lihaoyi
maybe; i no longer use SBT so I can’t help you
christobill
@christobill
Haha @lihaoyi 🙂. Honestly it’s not for me, some people in my team are blocked with this, and they want to stop using ammonite because of it. I tried mill yesterday, if the intellij support is good (it seems to be provided) then maybe it solves my problem
Jakub Dubovsky
@james64
How about my question about shell-scripting above? sorry to bump but I am really curious...
Li Haoyi
@lihaoyi
for scripting i would us the os.* APIs instead of ammonite.ops
you can import the ammonite.ops functions but os.* reads much better in my opinion
ziggystar
@ziggystar
Hi. I have a Path that refers to a file in ammonite-ops, and I want the directory portion of it (complement of baseName). How can I do this?
Jakub Dubovsky
@james64
@lihaoyi sounds good. Is there any brief doc for this lib so I have something to start with? I see just bunch of import os._s and os.Pathin method definitions but that's it. Maybe I am missing something...
Li Haoyi
@lihaoyi
myPath / os.up
plenty of docs there
ziggystar
@ziggystar
I'm trying to pipe from one %% process into another one. After reading the docs, I'm still left puzzling., How can I do this?
Li Haoyi
@lihaoyi
you can’t, use os.proc
Pascal Mengelt
@pme123
Haifeng Li
@haifengl
Is it possible to configure REPL to print expression result on a new line? My expressions toString generally creates a multi-line output (e.g. matrix, data frame, etc.). By default, REPL prints the data type and first line together, which breaks the format.
Haifeng Li
@haifengl
@lihaoyi any suggestions to my above question? Thanks!
Li Haoyi
@lihaoyi
you can mutate repl.pprinter() = to one that prints a newline first before delegating to the old one
Haifeng Li
@haifengl
Thanks. Can you please show the full code to do that? I don't get how to mutate it
Li Haoyi
@lihaoyi
you’ll have to figure it out
Jacob Taylor-Hindle
@GlassAndOneHalf

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?

Pascal Mengelt
@pme123
What happens if I have a Future in my Script? Will it run in the background forever?