-
Notifications
You must be signed in to change notification settings - Fork 1
/
repl
executable file
·42 lines (38 loc) · 1 KB
/
repl
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
#!/bin/zsh
# Copyright 2023 Google LLC
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
# Script to start a REPL with development environment conveniences.
# Usage: ./repl day1
set -e
DAY=${1:?missing day}
# ${(C)} is ucfirst
MODULE=${(C)DAY}
cd $DAY
export JULIA_LOAD_PATH=".:..:$JULIA_LOAD_PATH"
if [[ -z $SSH_TTY && -z $JULIA_EDITOR ]]; then
vims=($(whence gvim mvim vim || true))
export JULIA_EDITOR=${vims[1]}
fi
read -r -d '' STARTUP <<EOT || true
try
@eval using Debugger
catch e
@warn "Need to install Debugger?" exception=(e)
end
try
@eval using Revise
catch e
@warn "Need to install Revise?" exception=(e)
end
using $MODULE
using Runner
inputexample = "input.example.txt"
inputactual = "input.actual.txt"
run() = Runner.run_module($MODULE, Runner.inputfiles(); verbose=true)
Runner.inputstats()
println("$MODULE, just run() or $MODULE.part1(readlines(inputexample))")
EOT
exec julia -e "$STARTUP" -i