From 9c7a251c1dbff58b45151d93fdb17845f820dcb1 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 10 Nov 2020 10:53:33 +0100 Subject: dhall tools. --- .settings.sh | 7 +++++++ tools/.gitignore | 1 + tools/dhall | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/dhall-to-json | 1 + tools/dhall-to-yaml-ng | 1 + tools/json-to-dhall | 1 + tools/yaml-to-dhall | 1 + 7 files changed, 62 insertions(+) create mode 100644 .settings.sh create mode 100644 tools/.gitignore create mode 100755 tools/dhall create mode 120000 tools/dhall-to-json create mode 120000 tools/dhall-to-yaml-ng create mode 120000 tools/json-to-dhall create mode 120000 tools/yaml-to-dhall diff --git a/.settings.sh b/.settings.sh new file mode 100644 index 0000000..61442c9 --- /dev/null +++ b/.settings.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +basedir=$(dirname "$_") +basedir=$(cd "$basedir" && pwd) + +echo "Adding tools/ to path" +PATH="$basedir/tools:$PATH" diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000..ba077a4 --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1 @@ +bin diff --git a/tools/dhall b/tools/dhall new file mode 100755 index 0000000..ad71285 --- /dev/null +++ b/tools/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" "${@}" diff --git a/tools/dhall-to-json b/tools/dhall-to-json new file mode 120000 index 0000000..ffe753a --- /dev/null +++ b/tools/dhall-to-json @@ -0,0 +1 @@ +dhall \ No newline at end of file diff --git a/tools/dhall-to-yaml-ng b/tools/dhall-to-yaml-ng new file mode 120000 index 0000000..ffe753a --- /dev/null +++ b/tools/dhall-to-yaml-ng @@ -0,0 +1 @@ +dhall \ No newline at end of file diff --git a/tools/json-to-dhall b/tools/json-to-dhall new file mode 120000 index 0000000..ffe753a --- /dev/null +++ b/tools/json-to-dhall @@ -0,0 +1 @@ +dhall \ No newline at end of file diff --git a/tools/yaml-to-dhall b/tools/yaml-to-dhall new file mode 120000 index 0000000..ffe753a --- /dev/null +++ b/tools/yaml-to-dhall @@ -0,0 +1 @@ +dhall \ No newline at end of file -- cgit v1.2.3