From cf58bbdcf2d1e3765556b1b6e969a99aaf38b7da Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sun, 4 Aug 2024 20:45:15 -0400 Subject: [PATCH] Cleanup prompts --- workflow/qhtcp-workflow | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 5b561238..cdea3766 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -535,7 +535,7 @@ interactive_header() { Enter project number(s) to analyze: * A comma-separated list of project numbers (ex. 2,5,12) * 0 to add a new project - * Enter to accept the default (newest) project ($num) + * for the latest project ($num) EOF ((YES)) || read -r -p "($num): " response if [[ $response == 0 ]]; then @@ -566,8 +566,14 @@ interactive_header() { done if [[ ${#MODULES[@]} -eq 0 && ${#EXCLUDE_MODULES[@]} -eq 0 ]]; then - echo "Enter a comma-separated list of modules to run" - ((YES)) || read -r -p "Hit Enter for all (default) or '0' for none: " response + cat <<-EOF + Enter modules(s) to run: + * A comma-separated list of module numbers + * Example: 2,5,12 + * 0 for none + * for all modules (default) + EOF + ((YES)) || read -r -p "(all): " response if [[ -z $response ]]; then MODULES=("${ALL_MODULES[@]}") elif [[ $response -eq 0 ]]; then @@ -583,16 +589,21 @@ interactive_header() { if [[ ${#MODULES[@]} -eq 0 && ${#EXCLUDE_MODULES[@]} -eq 0 && ${#SUBMODULES[@]} -eq 0 ]]; then while :; do - echo "Enter a submodule followed by its arguments as a comma-separated string" - echo "Quote your string if there are any whitespaces" - echo "Example: ${ALL_SUBMODULES[0]} \"arg1,arg2,arg3...\"" - ((YES)) || read -r -p "Or hit Enter to continue: " response + cat <<-EOF + Enter submodules(s) to run followed by its arguments in a comma-separated string + * Quote your string if there are any whitespaces + * A comma-separated list of submodules and their arguments + * Both arguments are required + * Example: ${ALL_SUBMODULES[0]},\"arg1,arg2,arg3...\",${ALL_SUBMODULES[1]},\"arg1,arg2,arg3...\" + * for none (default) + EOF + ((YES)) || read -r -p "(none): " response [[ -z $response ]] && break - IFS=' ' read -ra arr <<< "$response" - if [[ ! ${#arr[@]} -eq 2 ]]; then - err "The second argument is required and may be an empty string, \"\"" - else + IFS=',' read -ra arr <<< "$response" + if [[ $((${#arr[@]} % 2)) -eq 0 ]]; then # check if array is even SUBMODULES+=("${arr[@]}") + else + err "The second argument is required (may be an empty string, \"\")" fi unset response arr i done