#!/usr/bin/env bash source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" APP=tile38 VERSION=${VERSION:-1.28.0} DEST="${XDG_DATA_HOME}/apps/releases/${APP}" install_zip () ( URL=https://github.com/tidwall/tile38/releases/download/${VERSION}/tile38-${VERSION}-$(get_os)-$(get_arch).zip extract_zip "${URL}" "${DEST}/${VERSION}" set_current_link "${DEST}" "${VERSION}" DEST_DIR=${DEST}/${VERSION}/tile38-${VERSION}-$(get_os)-$(get_arch) pushd "${DEST_DIR}" || exit 1 mv -v ./* ../ popd || exit 1 rmdir "${DEST_DIR}" set_link "${XDG_BIN_HOME}/tile38-benchmark" "${DEST}" tile38-benchmark set_link "${XDG_BIN_HOME}/tile38-cli" "${DEST}" tile38-cli set_link "${XDG_BIN_HOME}/tile38-server" "${DEST}" tile38-server ) install_targz () ( URL=https://github.com/tidwall/tile38/releases/download/${VERSION}/tile38-${VERSION}-$(get_os)-$(get_arch).tar.gz extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-component 1" set_current_link "${DEST}" "${VERSION}" set_link "${XDG_BIN_HOME}/tile38-benchmark" "${DEST}" tile38-benchmark set_link "${XDG_BIN_HOME}/tile38-cli" "${DEST}" tile38-cli set_link "${XDG_BIN_HOME}/tile38-server" "${DEST}" tile38-server ) case $(get_os) in darwin) install_zip;; freebsd) install_zip;; windows) install_zip;; linux) install_targz;; *) >&2 echo "unsupported os $(uname -s)"; exit 1;; esac