diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2020-11-10 10:53:33 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2020-11-10 10:53:33 +0100 |
commit | 9c7a251c1dbff58b45151d93fdb17845f820dcb1 (patch) | |
tree | b0b24be8a855bcf0c8a8e8094853101803bf0a24 | |
parent | fe9f038589d020e0d284af5127e1cb16452c0a56 (diff) | |
download | infra-9c7a251c1dbff58b45151d93fdb17845f820dcb1.tar.gz infra-9c7a251c1dbff58b45151d93fdb17845f820dcb1.tar.bz2 infra-9c7a251c1dbff58b45151d93fdb17845f820dcb1.tar.xz infra-9c7a251c1dbff58b45151d93fdb17845f820dcb1.zip |
dhall tools.
-rw-r--r-- | .settings.sh | 7 | ||||
-rw-r--r-- | tools/.gitignore | 1 | ||||
-rwxr-xr-x | tools/dhall | 50 | ||||
l--------- | tools/dhall-to-json | 1 | ||||
l--------- | tools/dhall-to-yaml-ng | 1 | ||||
l--------- | tools/json-to-dhall | 1 | ||||
l--------- | tools/yaml-to-dhall | 1 |
7 files changed, 62 insertions, 0 deletions
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 |