You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/scala-scripts/README.md
+18-8Lines changed: 18 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,26 +11,27 @@ Scala Scripts are files containing Scala code without main method required. Thes
11
11
12
12
You can use `scala-cli` to run Scala scripts (no further setup is required):
13
13
14
-
```scala name:HelloScript.sc
14
+
```scala title=HelloScript.sc
15
15
valsv= scala.util.Properties.versionNumberString
16
16
17
17
valmessage=s"Hello from Scala ${sv}, Java ${System.getProperty("java.version")}"
18
18
println(message)
19
19
```
20
20
21
-
```scala-cli
21
+
```bash
22
22
scala-cli run HelloScript.sc
23
23
```
24
24
25
-
<!-- Expected:
26
-
Hello from Scala *, Java *
25
+
<!-- Expected-regex:
26
+
Hello from Scala .*, Java .*
27
27
-->
28
28
29
29
30
30
Alternatively, add a shebang header to your script, make your script executable, and execute it directly. `scala-cli` needs to be installed for this to work.
All the features from non-scripts are working with Scala Scripts, such as waiting for changes (watch mode), dependencies menagement, packaging, compiling and many others.
53
58
54
59
### Package
55
60
56
-
Pass `--package` to the Scala CLI to package your script to Leighweight JAR file.
61
+
Run `package` to the Scala CLI to package your script to Leighweight JAR file.
57
62
58
63
```bash
59
-
scala-cli --package HelloScript.sc
64
+
scala-cli package HelloScript.sc
65
+
./HelloScript
60
66
```
61
67
68
+
<!-- Expected-regex:
69
+
Hello from Scala .*, Java .*
70
+
-->
71
+
62
72
### Watch mode
63
73
64
74
Pass `--watch` to the Scala CLI to watch all sources for changes, and re-run them upon changes.
0 commit comments