crit 0.0.17

Rust cross-compiler
Documentation
#!/bin/bash
unset IFS
set -euf

GH_FORK='mcandre'
APP='crit'
DEST="$HOME/.local/bin"

fallback() {
    echo "select another install method: https://github.com/$GH_FORK/$APP/blob/main/INSTALL.md" >&2
}

uname_to_rust_os() {
    case "$1" in
        Darwin*)
            echo 'apple-darwin'
            ;;
        FreeBSD*)
            echo 'unknown-freebsd'
            ;;
        Linux*)
            echo 'unknown-linux-musl'
            ;;
        NetBSD*)
            echo 'unknown-netbsd'
            ;;
        *illumos*)
            echo 'unknown-illumos'
            ;;
        *)
            echo "error: unsupported os. uname -a: $1" >&2
            fallback
            exit 1
            ;;
    esac
}

uname_arch_to_rust_arch() {
    case "$1" in
        aarch64 | arm64)
            echo 'aarch64'
            ;;
        x86_64)
            echo 'x86_64'
            ;;
        *)
            echo "error: unsupported arch. uname -a: $(uname -a)" >&2
            fallback
            exit 1
            ;;
    esac
}

UNAME="$(uname -a)"
OS="$(uname_to_rust_os "$UNAME")"
ARCH="$(uname_arch_to_rust_arch "$(uname -m)")"
TARBALL="$APP-$ARCH-$OS.tgz"
curl -LO "https://github.com/$GH_FORK/$APP/releases/latest/download/$TARBALL"
mkdir -p "$DEST"
tar -C "$DEST" -xzf "$TARBALL"
rm -rf "$TARBALL"
echo "installed $APP binaries to $DEST"