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
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?
Li Haoyi
@lihaoyi
@GlassAndOneHalf easiest thing to do is put it on a threadlocal
Jacob Taylor-Hindle
@GlassAndOneHalf
Hey @lihaoyi - how would I go about doing that? I can easily create a new threadlocal, but how does Ammonite pick that up?
Jacob Taylor-Hindle
@GlassAndOneHalf

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.

Jacob Taylor-Hindle
@GlassAndOneHalf
Ah - that was my bad. All is working now! Just need to fix some issues loading scripts under the resources folder.
Brian Maso
@bmaso
@GlassAndOneHalf +1. Wish I could bookmark that.
Ackerley Tng
@ackerleytng
@lihaoyi thanks so much for ammonite and great job!!
starting out in scala, was trying stuff out in ammonite - implicit conversions don't seem to take effect in the ammonite repl. is this expected behavior? (from Scala for the Impatient)
@ 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
@
Li Haoyi
@lihaoyi
Hi Ackerley!
not sure about JavaConversions
Theyve been deprecated for a while, wouldn’t be surprised if they don’t work properly these days
Trond Bjerkestrand
@tbje

@ackerleytng try

flavors.getNativesForFlavor(DataFlavor.imageFlavor).asScala

Worked well in my ammonite

Li Haoyi
@lihaoyi
(need to import collections.JavaConverters._ before that)
Ackerley Tng
@ackerleytng
I see, got it! so it isn't really implicit anymore. Thanks!
Eric K Richardson
@ekrich
JavaConversions were implicit but they are deprecated.
Ackerley Tng
@ackerleytng
I see, thanks!
Matthew de Detrich
@mdedetrich
Is it possible to create a forked process with ammonite-ops?
Li Haoyi
@lihaoyi
you can spawn processes using os.proc().spawn. You cannot fork JVMs https://jukkaz.wordpress.com/2010/05/27/forking-a-jvm/
Matthew de Detrich
@mdedetrich
Thanks