Skip to content

Commit

Permalink
Add docs to scripts.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Jul 12, 2022
1 parent 266cae0 commit 899a664
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions website/docs/commands/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object Utils {

```bash
scala-cli Main.scala
# Hello World
```

<!-- Expected:
Expand Down
26 changes: 26 additions & 0 deletions website/docs/guides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,32 @@ world
</ChainedSnippets>
### Define source files in using directives
You can also add source files with the using directive `//> using file` in Scala Scripts:
```scala title=main.sc
//> using file "Utils.scala"
println(Utils.message)
```
```scala title=Utils.scala
object Utils {
val message = "Hello World"
}
```
`scala-cli` compiles and adds to the class path source `Utils.scala`.
```bash
scala-cli main.sc
# Hello World
```
<!-- Expected:
Hello World
-->
### Difference with Ammonite scripts
[Ammonite](http://ammonite.io) is a popular REPL for Scala that can also compile and run `.sc` files.
Expand Down

0 comments on commit 899a664

Please sign in to comment.