#!/usr/bin/env bash
# Copyright (c) 2017-2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail

bin_dir="$HOME/.jq/bin"

function install {
    if ! link ; then
        mkdir -p "${bin_dir}"
        curl -sSL https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o "${bin_dir}/jq" 
        chmod 755 "${bin_dir}/jq"
        link
    fi
}

function link {
    mkdir -p "$HOME/bin"
    [ -f "${bin_dir}/jq" ] && \
        ln -s "${bin_dir}/jq" "$HOME/bin/"
}

install
