In order to start sbt, open a terminal (“Command Prompt” in Windows) and navigate to the directory of the assignment you are working on. Typing sbt will open the sbt command prompt.
% cd /path/to/progfun-project-directory
% sbt
> _
This is the sbt shell
You can start the Scala interpreter inside sbt using the console task. The interpreter (also called REPL, for “read-eval-print loop”) is useful for trying out snippets of Scala code. Note that the interpreter can only be started if there are no compilation errors in your code.
In order to quit the interpreter and get back to sbt, type ctrl-d.
> console
scala> println("Oh, hai!")
val l = List(1, 2, 3)
val squares = l.map(x => x * x)
Type [ctrl-d] to exit the Scala REPL
The compile task will compile the source code of the assignment which is located in the directory src/main/scala.
> compile
If the source code contains errors, the error messages from the compiler will be displayed.
The directory src/test/scala contains unit tests for the project. In order to run these tests in sbt, you can use the test command.
> test
If your project has an object with a main method (or an object extending the trait App), then you can run the code in sbt easily by typing run. In case sbt finds multiple main methods, it will ask you which one you’d like to execute.
> run
As part of the grading process, we rung a style checker on the submitted source code to find commond coding style issues. To make sure that your code conforms to all our style rules, you can run the style checker yourself before submitting. The sbt task styleCheck does exactly that.
> styleCheck