Motivation
Have a boilerplate code for parsing comand line argument into bash scripts to speed up transition from a script to a working command line tool
getopts
this enables parsing command line arguments
Example of parsing block
TEMP=$(getopt
-o c:s:m:h:
–long color:,stroke:,margin:,height:
-n “$0” – “$@”)
if [ $? -ne 0 ]; then
exit 1
fi
eval set – “$TEMP”
while true; do case “$1” in -c|–color) COLOR="$2" shift 2 ;; -s|–stroke) STROKE="$2" shift 2 ;; -m|–margin) MARGIN="$2" shift 2 ;; -h|–height) RELHEIGHT="$2" shift 2 ;; –) shift break ;; *) exit 1 ;; esac done