Skip to content

Commit 01048b0

Browse files
committed
started kshell launcher for kscriptlets
1 parent f385201 commit 01048b0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

misc/kshell_launcher/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Create kshell terminals from a kscript
2+
3+
4+
Based on https://github.com/khud/sparklin which is a proof-of-concept software that includes experimental new Kotlin REPL.
5+
6+
## Installation
7+
8+
```bash
9+
wget https://raw.githubusercontent.com/holgerbrandl/kscript/master/misc/kshell_launcher/kshell_from_kscript.sh
10+
chmod +x kshell_from_kscript.sh
11+
```
12+
13+
You may want to add it to your `PATH` as well.
14+
15+
## Usage
16+
17+
Simply provide any kscript as argument. E.g [`krangl_example.kts`]()
18+
```
19+
kshell_from_kscript.sh krangl_example.kts
20+
```
21+
22+
## Todo
23+
24+
* bundle this with kscript itself
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@file:DependsOn("com.offbytwo:docopt:0.6.0.20150202", "log4j:log4j:1.2.14")
2+
@file:DependsOn("de.mpicbg.scicomp:krangl:0.9.1")
3+
4+
import krangl.flightsData
5+
import krangl.schema
6+
7+
8+
flightsData.schema()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
4+
if [ $# -ne 1 ]; then
5+
echo "Usage: kshell_from_kscript.sh <kscript.kts>"
6+
exit 0
7+
fi
8+
9+
tmpfile=$(mktemp).kts
10+
11+
echo '@file:Include("https://git.io/fAJ5h")' >> $tmpfile
12+
echo '' >> $tmpfile
13+
14+
argScript=$1
15+
#argScript=krangl_example.kts
16+
17+
cat $argScript >> $tmpfile
18+
19+
#cat $tmpfile
20+
21+
22+
echo "Preparing interactive session by resolving script dependencies..."
23+
24+
## resolve dependencies without running the kscript
25+
KSCRIPT_DIR=$(dirname $(which kscript))
26+
kscript_nocall() { kotlin -classpath ${KSCRIPT_DIR}/kscript.jar kscript.app.KscriptKt "$@";}
27+
28+
kshellCP=$(kscript_nocall $tmpfile | cut -d' ' -f4)
29+
30+
## create new
31+
exec java -classpath "${kshellCP}" sparklin.kshell.KotlinShell $@

0 commit comments

Comments
 (0)