Skip to content

Commit 35a4d2f

Browse files
authored
Merge pull request #40 from axelnilsson98/master
added instructions for scala-cli
2 parents 97a32d1 + b8b4d73 commit 35a4d2f

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

docs/index.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,38 @@ The open source code is hosted at [[https://github.com/lunduniversity/introprog-
1818

1919
- [[introprog.examples]] with code examples demonstrating how to use this library.
2020

21-
## How to use this library with `sbt`
21+
## How to use introprog-scalalib
22+
23+
### Using scala-cli
24+
25+
You need [Scala Command Line Interface](https://scala-cli.virtuslab.org/install) at least version 0.1.5.
26+
27+
Add these magic comment lines starting with `//>` in the beginning of your Scala 3 file:
28+
29+
```
30+
//> using scala "3"
31+
//> using lib "se.lth.cs::introprog:1.3.1"
32+
```
33+
34+
You run your code with `scala-cli run .` (note the ending dot, meaning "this dir")
35+
36+
If your program looks like this:
37+
38+
```
39+
//> using scala "3"
40+
//> using lib "se.lth.cs::introprog:1.3.1"
41+
42+
@main def run =
43+
val w = introprog.PixelWindow()
44+
w.drawText("Hello introprog.PixelWindow!", x = 100, y = 100)
45+
```
46+
You should see green text in a new window after executing:
47+
```
48+
scala-cli run .
49+
```
50+
See: [api documentation for PixelWindow](https://fileadmin.cs.lth.se/pgk/api/api/introprog/PixelWindow.html)
51+
52+
### Using sbt
2253

2354
If you have [sbt](https://www.scala-sbt.org/) installed then you can put this text in a file called `build.sbt`
2455

0 commit comments

Comments
 (0)