Frage

I'm breaking myself into Scala. I got "Hello, World" to echo on the terminal. WOOT!

Here's my new problem: Run rails new <app> by running it with scala. Improvement: It will cd into the <app> folder it will make and then run git init for you.

This is my problem and I want to make the bash script with Scala.

Here was my Hello World script (complete copy from scala lang):

#!/bin/sh
exec scala "$0" "$@"
!#
object HelloWorld extends App {
  println("Hello, World")
}
HelloWorld.main(args)

Does anyone know how to do this? Or how I could at least run ls with the terminal?

Also, is there a way to handle errors with a bash script?

War es hilfreich?

Lösung

You can look at how a plugin like sbt/sbt-git does implement calls to git.

See the sbt/git/ConsoleGitRunner.scala:

private lazy val cmd = if(isWindowsShell) Seq("cmd", "/c", "git") else Seq("git")

It uses sbt.Process.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top