Implement Precedence
[clnl] / bin / runcmd.scala
1 #!/bin/sh
2 exec scalas "$0" -q "$@"
3 !#
4
5 /***
6   logLevel := Level.Error
7
8   logLevel in Global := Level.Error
9
10   scalaVersion := "2.9.2"
11
12   libraryDependencies ++= Seq(
13     "asm" % "asm-all" % "3.3.1",
14     "org.picocontainer" % "picocontainer" % "2.13.6",
15     "org.nlogo" % "NetLogo" % "5.2.0" from "http://ccl.northwestern.edu/netlogo/5.2.0/NetLogo.jar"
16   )
17 */
18
19 import org.nlogo.headless.HeadlessWorkspace
20 import org.nlogo.api
21 import org.nlogo.nvm
22 import org.nlogo.util.Utils.url2String
23
24 import collection.JavaConversions._
25
26 System.out.println("----")
27 val workspace = HeadlessWorkspace.newInstance
28 workspace.silent = true
29 workspace.openFromSource(url2String("file:resources/empty.nlogo"))
30
31 val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@")
32 val commands = input(0)
33
34 workspace.mainRNG.setSeed(15)
35 if(commands.length > 0) {
36   workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileCommands(commands))
37 }
38 if(input.length > 1) {
39   val reporter = input(1)
40   System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileReporter(reporter))))
41 }
42
43 workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)
44 System.out.println(org.nlogo.headless.Checksummer.calculateChecksum(workspace.world.exportWorld(_, true)))
45
46 workspace.dispose