aboutsummaryrefslogtreecommitdiff
path: root/bin/dhall
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dhall')
-rwxr-xr-xbin/dhall50
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/dhall b/bin/dhall
new file mode 100755
index 0000000..ad71285
--- /dev/null
+++ b/bin/dhall
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+v_dhall=1.36.0
+v_dhall_yaml=1.2.3
+v_dhall_json=1.7.3
+
+set -eu
+
+basedir=$(dirname "$0")
+
+cmd="$(basename $0)"
+
+case $cmd in
+ dhall)
+ tar=dhall
+ v=$v_dhall
+ ;;
+ dhall-to-json|json-to-dhall)
+ tar=dhall-json
+ v=$v_dhall_json
+ ;;
+ dhall-to-yaml-ng|yaml-to-dhall)
+ tar=dhall-yaml
+ v=$v_dhall_yaml
+ ;;
+ *)
+ echo "Unknown command: $0"
+ exit 1
+esac
+
+bin="$basedir/bin/$cmd-$v"
+tar_path="$basedir/bin/$tar-$v.tar.bz2"
+
+m="$(uname -m)"
+s="$(uname -s|tr [:upper:] [:lower:])"
+
+if [ ! -r "$tar_path" ]
+then
+ mkdir -p "$(dirname $tar_path)"
+ wget -O "$tar_path" \
+ https://github.com/dhall-lang/dhall-haskell/releases/download/$v_dhall/$tar-$v-$m-$s.tar.bz2
+fi
+
+if [ ! -x "$bin" ]
+then
+ tar Oxf "$tar_path" ./bin/$cmd > "$bin"
+ chmod +x "$bin"
+fi
+
+exec "$bin" "${@}"