#!/bin/bash

# |||||- Pre-Configurations -|||||

diselect() {
    PS3='Please enter your choice: '
    select opt in "${options[@]}"
    do
        case $opt in
            1|"${options[0]}")
                ${option_c[0]}
                break
                ;;
            2|"${options[1]}")
                ${option_c[1]}
                break
                ;;
            3|"${options[2]}")
                ${option_c[2]}
                break
                ;;
            4|"${options[3]}")
                ${option_c[3]}
                break
                ;;
            5|"${options[4]}")
                ${option_c[4]}
                break
                ;;
            *) echo "invalid option, try again" ;;

        esac
    done

}

# |||||- Functions -|||||

check_internet() {
    ping -c 2 archlinux.org && check_intenet_state=true || check_intenet_state=false
    if [[ $check_intenet_state = false ]]
    then
        echo "No internet.. Exiting..."
        exit 2
    fi
}

update_time() {
    timedatectl set-ntp true
}

dialog_partition_disks() {
    options=("cfdisk" "fdisk" "I already partitioned my disks")
    option_c=("fun_cfdisk" "fun_fdisk" "echo")
    diselect
}

dialog_drive_list() {
    echo "Please enter your drive to be partitioned in the format '/dev/sda'"
    read -p "-> " var_drive
   
}
fun_cfdisk() {
    dialog_drive_list
    cfdisk $var_drive

}


# |||||- Execution -|||||

check_internet

dialog_partition_disks
