<commit_before>#!/bin/bash

# This is just a little script that can be downloaded from the internet to
# install nmkup. It just does platform detection, downloads the installer
# and runs it.

set -u

# If NMKUP_UPDATE_ROOT is unset or empty, default it.
NMKUP_UPDATE_ROOT="${NMKUP_UPDATE_ROOT:-https://storage.googleapis.com/nmk.nuimk.com/nmk.rs}"

#XXX: If you change anything here, please make the same changes in setup_mode.rs
usage() {
    cat 1>&2 <<EOF
nmkup 0.1.0
All in one binary to setup nmk

USAGE:
    nmkup [FLAGS]

FLAGS:
    -f, --force      Force install
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v               Request verbose logging
EOF
}

main() {
    downloader --check
    need_cmd uname
    need_cmd mktemp
    need_cmd chmod
    need_cmd mkdir
    need_cmd rm
    need_cmd rmdir

    get_architecture || return 1
    local _arch="$RETVAL"
    assert_nz "$_arch" "arch"


    local _ext=""
    case "$_arch" in
        *windows*)
            _ext=".exe"
            ;;
    esac

    local _url
    case "$_arch" in
        x86_64-unknown-linux-gnu)
            _url="${NMKUP_UPDATE_ROOT}/nmkup-amd64-linux-musl"
            ;;
        armv7-unknown-linux-gnueabihf)
            _url="${NMKUP_UPDATE_ROOT}/nmkup-armv7-linux"
            ;;
        *)
            err "Unsupported arch: $_arch"
        ;;
    esac

    local _dir
    _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t nmkup)"
    local _file="${_dir}/nmkup-init${_ext}"

    local _ansi_escapes_are_valid=false
    if [ -t 2 ]; then
        if [ "${TERM+set}" = 'set' ]; then
            case "$TERM" in
                xterm*|rxvt*|urxvt*|linux*|vt*)
                    _ansi_escapes_are_valid=true
                ;;
            esac
        fi
    fi

    # check if we have to use /dev/tty to prompt the user<commit_msg>Fix installation script<commit_after>#!/bin/bash

# This is just a little script that can be downloaded from the internet to
# install nmkup. It just does platform detection, downloads the installer
# and runs it.

set -u

# If NMKUP_UPDATE_ROOT is unset or empty, default it.
NMKUP_UPDATE_ROOT="${NMKUP_UPDATE_ROOT:-https://storage.googleapis.com/nmk.nuimk.com/nmk.rs}"

#XXX: If you change anything here, please make the same changes in setup_mode.rs
usage() {
    cat 1>&2 <<EOF
nmkup 0.1.0
All in one binary to setup nmk

USAGE:
    nmkup [FLAGS]

FLAGS:
    -f, --force      Force install
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v               Request verbose logging
EOF
}

main() {
    downloader --check
    need_cmd uname
    need_cmd mktemp
    need_cmd chmod
    need_cmd mkdir
    need_cmd rm
    need_cmd rmdir

    get_architecture || return 1
    local _arch="$RETVAL"
    assert_nz "$_arch" "arch"


    local _ext=""
    case "$_arch" in
        *windows*)
            _ext=".exe"
            ;;
    esac

    local _url
    case "$_arch" in
        x86_64-unknown-linux-gnu | x86_64-unknown-linux-musl)
            _url="${NMKUP_UPDATE_ROOT}/nmkup-amd64-linux-musl"
            ;;
        armv7-unknown-linux-gnueabihf)
            _url="${NMKUP_UPDATE_ROOT}/nmkup-armv7-linux"
            ;;
        *)
            err "Unsupported arch: $_arch"
        ;;
    esac

    local _dir
    _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t nmkup)"
    local _file="${_dir}/nmkup-init${_ext}"

    local _ansi_escapes_are_valid=false
    if [ -t 2 ]; then
        if [ "${TERM+set}" = 'set' ]; then
            case "$TERM" in
                xterm*|rxvt*|urxvt*|linux*|vt*)
                    _ansi_escapes_are_valid=true
                ;;
            esac
        fi
    fi

    # check if we have to use /dev/tty to prompt the user
{'fraction_non_alphanumeric': 0.10670892762810354, 'fraction_numerical': 0.009508716323296355, 'mean_word_length': 2.0199362041467306, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6861532', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1266, 'n_words': 350}