q-wbs - Create a new WBS from a template

#!/usr/bin/env bash
help_text="
usage: q-wbs [options] <wbs_filename>
-h : This help text.

Creates a new WBS in the current directory with the given filename.
"

help_line="Create a new WBS from a template"
web_desc_line="Create a new WBS from a template"

case $1 in
    -h|--help)
        echo "$help_text"
        exit
        ;;
esac

if [[ "$1" == "" ]]; then
    echo "$help_text"
    exit 1
fi

new_file="$1"

if [[ "$new_file" =~ [^a-zA-Z0-9._-] ]]; then
    echo "Error: Filename can only contain letters, numbers, full-stops, hyphens and underscores."
    exit 1
fi

tmp_file="/tmp/q-wbs.txt"
current_dir="$(pwd)"

cd "/c/Users/MartinNurse/OneDrive - Quantexa Ltd/Documents - Quantexa - Technology/Architecture/Effort estimates"

ls *WBS*.xlsx > $tmp_file

i=1
echo
echo "Available WBS templates:"
echo
while read line; do
    echo $i - $line
    i=$((i+1))
done < $tmp_file

echo
read -p "Select WBS file number: " file_number

if ! [[ "$file_number" =~ ^[0-9]+$ ]]; then
    echo "Error: Please enter a valid number."
    exit 1
fi

selected_file=$(sed -n "${file_number}p" $tmp_file)

if [[ "$selected_file" == "" ]]; then
    echo "Error: Invalid selection."
    exit 1
fi

cp "$selected_file" "$current_dir/$new_file.xlsx"
ms-office "$current_dir/$new_file.xlsx"