Created
March 29, 2019 11:08
-
-
Save JanGalek/658fa1ab575efcf88892d7566bead50d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -A variables2=() | |
declare prev_var='' | |
showHelp() | |
{ | |
echo "Basic help" | |
echo "----------" | |
for i in "${!setupVars[@]}"; do | |
echo "${i}" | |
done | |
echo "--help|-h show this help" | |
} | |
for i in "$@"; do | |
parameter=$(echo ${i} | grep -E '^\-{1,2}[a-zA-Z0-9]+$') | |
if [[ ${parameter} == "--help" || ${parameter} == "-h" ]]; then | |
showHelp | |
exit 0 | |
elif [[ ${parameter} != "" && ${setupVars[$i]} ]]; then | |
variables2[$i]="" | |
prev_var=${i} | |
declare ${setupVars[$i]}="" | |
elif [[ ${parameter} != "" ]]; then | |
echo ${parameter} is not available and will be ignored. | |
elif [[ ${prev_var} == "" ]]; then | |
echo "${parameter} $i cannot be set to variable and will be ignored (you can use it as \$1)." | |
else | |
variables2[$prev_var]="${variables2[$prev_var]} ${i}" | |
declare ${setupVars[${prev_var}]}="${variables2[$prev_var]}" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; | |
declare -A setupVars=() | |
setupVars["--src"]="sources" | |
setupVars["--fix"]="fix" | |
source ${SCRIPT_DIR}/../bin/scripts/includes/flags.sh | |
echo sources: ${sources} | |
echo fix: ${fix} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment