forked from VirtusLab/scala-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripting.sh
executable file
·63 lines (46 loc) · 1.15 KB
/
scripting.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
########################
# include the magic
########################
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
if [[ -z "${ASCIINEMA_REC}" ]]; then
# Warm up scala-cli
echo "println(1)" | scala-cli -
echo "//> using dep \"com.lihaoyi::os-lib::0.9.1\"" | scala-cli -
# or do other preparation (e.g. create code)
else
. $SCRIPT_DIR/../demo-magic.sh
# # hide the evidence
clearConsole
# Put your stuff here
cat <<EOF | updateFile file
Hello World from file
EOF
cat <<EOF | updateFile script.sc
//> using dep com.lihaoyi::os-lib::0.9.1
val filePath = os.pwd / "file"
val fileContent = os.read(filePath)
println(fileContent)
EOF
pe "scala-cli script.sc"
doSleep 5
clearConsole
cat <<EOF | updateFile hello.sc
val message = "Hello from Scala script"
println(message)
EOF
pe "scala-cli hello.sc"
doSleep 5
clearConsole
cat <<EOF | updateFile scala-script.sc
#!/usr/bin/env scala-cli
println("Hello world")
EOF
pe "chmod +x scala-script.sc"
pe "./scala-script.sc"
echo " "
# Wait a bit to read output of last command
doSleep 2
echo " " && echo "ok" > status.txt
fi