# shellcheck shell=bash disable=2154,SC3030,SC2207

___x_cmd_install___advise_ls_os_installer(){
    # TODO: Need to be removed in the future
    ___x_cmd_install_update___check || return $?

    local IFS="$___X_CMD_UNSEENCHAR_NEWLINE"
    local cur="${1:-"$cur"}"
    if [ "${cur%%/*}" = "$cur" ]; then
        candidate_nospace_arr=( $( ___x_cmd_install___advise_ls_os "$cur" ) )
    else
        candidate_exec_arr=( $(___x_cmd_install___advise_ls_installer "$cur" ))
    fi
}

___x_cmd_install___advise_ls_os(){
    local cur="$1"
    local l; local os; while read -r l; do
        os="${l%:}"
        [ "$os" = "$l" ] || {
            [ -z "$cur" ] || [ "$os" != "${os#"$cur"}" ] || continue
            printf "%s\n" "${os}/"
        }
    done < "${___X_CMD_INSTALL_DATA}/advise.yml"
    printf "%s\n" "/curl"
    printf "%s\n" "/wget"
    printf "%s\n" "/snap"
    printf "%s\n" "/msys2"
}

___x_cmd_install___advise_ls_installer(){
    local cur="$1"
    local os="${cur%%/*}"
    local l; local this_os=; while read -r l; do
        if [ -z "$this_os" ]; then
            [ "$os" != "${l%:}" ] || this_os=1
            continue
        else
            [ "$l" = "${l%:}" ] || return $?
            printf "%s\n" "${os}/${l#*- }"
        fi
    done < "${___X_CMD_INSTALL_DATA}/advise.yml"
}
