Skip to content

Commit 60de71b

Browse files
committed
[#720] Add example with scala and sbt
1 parent 65cbfc2 commit 60de71b

File tree

10 files changed

+116
-0
lines changed

10 files changed

+116
-0
lines changed

examples/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Here are some simple examples for using TCR with various languages & toolchains
5757
- With [cargo](rust-cargo/README.md)
5858
- With [nextest](rust-nextest/README.md)
5959

60+
## Scala
61+
62+
- With [sbt](scala-sbt/README.md)
63+
6064
## TypeScript
6165

6266
- With [yarn](typescript-yarn/README.md)

examples/scala-sbt/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.metals/
2+
.bloop/
3+
.bsp/
4+
project/
5+
target/
6+
.scalafmt.conf
7+
*.class
8+
*.tasty
9+

examples/scala-sbt/.tcr/config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
config:
2+
git:
3+
auto-push: false
4+
polling-period: 2s
5+
mob-timer:
6+
duration: 5m0s
7+
tcr:
8+
language: scala
9+
toolchain: sbt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
toolchains:
2+
default: sbt
3+
compatible-with: [ sbt ]
4+
source-files:
5+
directories: [ src/main ]
6+
patterns: [ '(?i)^.*\.scala$' ]
7+
test-files:
8+
directories: [ src/test ]
9+
patterns: [ '(?i)^.*\.scala$' ]
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build:
2+
- os: [ darwin, linux, windows ]
3+
arch: [ "386", amd64, arm64 ]
4+
command: sbt
5+
arguments: [ compile ]
6+
test:
7+
- os: [ darwin, linux, windows ]
8+
arch: [ "386", amd64, arm64 ]
9+
command: sbt
10+
arguments: [ test ]
11+
test-result-dir: target/test-reports

examples/scala-sbt/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Using TCR with Scala and sbt
2+
3+
## Prerequisites
4+
5+
- macOS, Linux or Windows
6+
- [git](https://git-scm.com/) client
7+
- [curl](https://curl.se/download.html) command line utility
8+
- [java SDK](https://www.oracle.com/java/technologies/downloads/) with `JAVA_HOME` environment variable properly set up
9+
- [scala](https://www.scala-lang.org/download/)
10+
- [sbt](https://www.scala-sbt.org/download/)
11+
12+
## Instructions
13+
14+
### 1 - Open a terminal
15+
16+
> ***Note to Windows users***
17+
>
18+
> Use a **git bash** terminal for running the commands below.
19+
> _Windows CMD and PowerShell are not supported_
20+
21+
### 2 - Launch TCR
22+
23+
> ***Reminder***: the command below should be run from
24+
> [examples/scala-sbt](.)
25+
> directory
26+
27+
From the built-in terminal:
28+
29+
```shell
30+
./tcrw
31+
```
32+
33+
### Cheat Sheet
34+
35+
Here are the main shortcuts available once TCR utility is running:
36+
37+
| Shortcut | Description |
38+
|-----------|----------------------------------------------|
39+
| `o` / `O` | Open in browser (with `web` subcommand only) |
40+
| `d` / `D` | Enter driver role |
41+
| `n` / `N` | Enter navigator role |
42+
| `t` / `T` | Query timer status |
43+
| `p` / `P` | Toggle on/off git auto-push |
44+
| `l` / `L` | Pull from remote |
45+
| `s` / `S` | Push to remote |
46+
| `a` / `A` | Abort current command (when in driver role) |
47+
| `q` / `Q` | Quit current role / Quit TCR |
48+
| `?` | List available options |
49+
50+
### Additional Details
51+
52+
Refer to [tcr.md](../../doc/tcr.md) page for additional details and explanations about TCR
53+
available subcommands and options

examples/scala-sbt/build.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
scalaVersion := "3.4.2"
2+
3+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.18" % "test"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object HelloWorld {
2+
def sayHello(name: String): String = s"Hello, $name!"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.scalatest.funsuite.AnyFunSuite
2+
import org.scalatest.matchers.should.Matchers
3+
4+
5+
/** @version 1.1.0 */
6+
class HelloWorldTest extends AnyFunSuite with Matchers {
7+
8+
test("Say Hello") {
9+
HelloWorld.sayHello("Sue") should be ("Hello, Sue!")
10+
}
11+
}

examples/scala-sbt/tcrw

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
base_dir="$(cd "$(dirname -- "$0")" && pwd)"
4+
. "${base_dir}/../tcr/tcr.sh"

0 commit comments

Comments
 (0)