Cleanup main loop

This commit is contained in:
2024-08-04 21:17:27 -04:00
parent 67099f1328
commit 6a03b3fc7a

View File

@@ -532,12 +532,13 @@ interactive_header() {
for ((c=1; c<2; c++)); do # safe loop that only runs once for ((c=1; c<2; c++)); do # safe loop that only runs once
echo echo
cat <<-EOF cat <<-EOF
Enter project number(s) to analyze: Enter project number(s) to analyze:
* A comma-separated list of project numbers (ex. 2,5,12) * <Enter> for the latest project ($num) (default)
* A comma-separated list of project numbers (2,5,12)
* 0 to add a new project * 0 to add a new project
* <Enter> for the latest project ($num)
EOF EOF
((YES)) || read -r -p "($num): " response ((YES)) || read -r -p "($num): " response
echo ""
if [[ $response == 0 ]]; then if [[ $response == 0 ]]; then
ask_pn && PROJECTS+=("${ADD_PROJECTS[@]}") ask_pn && PROJECTS+=("${ADD_PROJECTS[@]}")
else else
@@ -567,13 +568,13 @@ interactive_header() {
if [[ ${#MODULES[@]} -eq 0 && ${#EXCLUDE_MODULES[@]} -eq 0 ]]; then if [[ ${#MODULES[@]} -eq 0 && ${#EXCLUDE_MODULES[@]} -eq 0 ]]; then
cat <<-EOF cat <<-EOF
Enter modules(s) to run: Enter modules(s) to run:
* A comma-separated list of module numbers * <Enter> for all (default)
* Example: 2,5,12 * A comma-separated list of module numbers (2,5,12)
* 0 for none * 0 for none
* <Enter> for all modules (default)
EOF EOF
((YES)) || read -r -p "(all): " response ((YES)) || read -r -p "(all): " response
echo ""
if [[ -z $response ]]; then if [[ -z $response ]]; then
MODULES=("${ALL_MODULES[@]}") MODULES=("${ALL_MODULES[@]}")
elif [[ $response -eq 0 ]]; then elif [[ $response -eq 0 ]]; then
@@ -591,13 +592,14 @@ interactive_header() {
while :; do while :; do
cat <<-EOF cat <<-EOF
Enter submodules(s) to run followed by its arguments in a comma-separated string Enter submodules(s) to run followed by its arguments in a comma-separated string
* Quote your string if there are any whitespaces * <Enter> for none (default)
* A comma-separated list of submodules and their arguments * A comma-separated list of submodules and their arguments
* Both arguments are required * Both arguments are required
* Quote the argument string if it contains whitespace
* Example: ${ALL_SUBMODULES[0]},\"arg1,arg2,arg3...\",${ALL_SUBMODULES[1]},\"arg1,arg2,arg3...\" * Example: ${ALL_SUBMODULES[0]},\"arg1,arg2,arg3...\",${ALL_SUBMODULES[1]},\"arg1,arg2,arg3...\"
* <Enter> for none (default)
EOF EOF
((YES)) || read -r -p "(none): " response ((YES)) || read -r -p "(none): " response
echo ""
[[ -z $response ]] && break [[ -z $response ]] && break
IFS=',' read -ra arr <<< "$response" IFS=',' read -ra arr <<< "$response"
if [[ $((${#arr[@]} % 2)) -eq 0 ]]; then # check if array is even if [[ $((${#arr[@]} % 2)) -eq 0 ]]; then # check if array is even
@@ -1262,10 +1264,17 @@ qhtcp() {
if [[ -d $QHTCP_PROJECT_DIR ]]; then if [[ -d $QHTCP_PROJECT_DIR ]]; then
# Handle existing output directory # Handle existing output directory
echo "A project already exists at $QHTCP_PROJECT_DIR" cat <<-EOF
echo "Would you like to (c)ontinue, (u)pdate it from the template and continue, or (b)ack it up and continue from scratch?" A project already exists at $QHTCP_PROJECT_DIR
Would you like to
* (c)ontinue (default)
* (u)pdate it from the template and continue
* (b)ack it up and start from scratch
EOF
for i in {1..3}; do # give the user three chances to get it right for i in {1..3}; do # give the user three chances to get it right
((YES)) || read -r -p "Hit [Enter] or c to continue: " response ((YES)) || read -r -p "(c): " response
echo ""
[[ -z $response ]] && break [[ -z $response ]] && break
case $response in case $response in
u) u)