Cleanup exlcude module code

This commit is contained in:
2024-08-01 22:53:04 -04:00
parent 72610d282d
commit 22ee074758

View File

@@ -130,7 +130,8 @@ print_help() {
# @section User Input # @section User Input
# @set PROJECTS array List of projects to work on # @set PROJECTS array List of projects to work on
# @set INCLUDE_MODULES array List of modules to run # @set MODULES array List of modules to run
# @set SUBMODULES array List of submodules and their arguments to run
# @set EXCLUDE_MODULES array List of modules not to run # @set EXCLUDE_MODULES array List of modules not to run
# @set DEBUG int Turn debugging on # @set DEBUG int Turn debugging on
# @set YES int Turn assume yes on # @set YES int Turn assume yes on
@@ -152,7 +153,7 @@ parse_input() {
;; ;;
--module|-m) --module|-m)
shift shift
IFS=',' read -ra INCLUDE_MODULES <<< "$1" IFS=',' read -ra MODULES <<< "$1"
;; ;;
--submodule|-s) --submodule|-s)
shift shift
@@ -344,7 +345,7 @@ print_header() {
unset response arr i unset response arr i
fi fi
if [[ -z ${MODULES[*]} && -z ${INCLUDE_MODULES[*]} && -z ${EXCLUDE_MODULES[*]} ]]; then if [[ -z ${MODULES[*]} && -z ${EXCLUDE_MODULES[*]} ]]; then
echo "Enter module #'s to run (by #, comma delimited)" echo "Enter module #'s to run (by #, comma delimited)"
((YES)) || read -r -p "Or hit Enter for default (ALL): " response ((YES)) || read -r -p "Or hit Enter for default (ALL): " response
if [[ -n $response ]]; then if [[ -n $response ]]; then
@@ -356,7 +357,7 @@ print_header() {
unset response arr i unset response arr i
fi fi
if [[ -z ${MODULES[*]} && -z ${INCLUDE_MODULES[*]} && -z ${EXCLUDE_MODULES[*]} && -z ${SUBMODULES[*]} ]]; then if [[ -z ${MODULES[*]} && -z ${EXCLUDE_MODULES[*]} && -z ${SUBMODULES[*]} ]]; then
while :; do while :; do
echo "Enter a submodule followed by its arguments as a case delimited string in quotes" echo "Enter a submodule followed by its arguments as a case delimited string in quotes"
echo "Example: ${ALL_SUBMODULES[0]} \"arg1,arg2,arg3...\"" echo "Example: ${ALL_SUBMODULES[0]} \"arg1,arg2,arg3...\""
@@ -1668,20 +1669,10 @@ main() {
fi fi
done done
# If we don't catch with getopt or env, run all
if [[ ${#INCLUDE_MODULES[@]} -eq 0 ]]; then
MODULES=("${ALL_MODULES[@]}")
else
MODULES=("${INCLUDE_MODULES[@]}")
fi
# Exclude modules from --exclude # Exclude modules from --exclude
arr=() for i in "${!MODULES[@]}"; do
for m in "${MODULES[@]}"; do [[ " ${EXCLUDE_MODULES[*]} " =~ [[:space:]]${MODULES[i]}[[:space:]] ]] && unset "MODULES[i]"
[[ " ${EXCLUDE_MODULES[*]} " =~ [[:space:]]${m}[[:space:]] ]] || arr+=("$m")
done done
MODULES=("${arr[@]}")
unset arr
# Sanitize MODULES # Sanitize MODULES
for i in "${!MODULES[@]}"; do for i in "${!MODULES[@]}"; do