diff --git a/install.sh b/install.sh index 287a34f..8b792ac 100644 --- a/install.sh +++ b/install.sh @@ -1,28 +1,51 @@ #!/bin/bash function show_help { - echo "This is the help" + echo "Usage: install.sh [cmd] [ -y | --yes ] [ -h | --help ] [ -m | --arch ARCH-STRING ] [ -d | --debug ] + [ -d | --delta DELTA ] filename(s)" + echo "Available commands: + update + install" + exit 2 } +PARSED_ARGUMENTS=$(getopt -a -n install.sh -o hvyi:acrbm:p --long yes,help,debug,arch: -- "$@") +VALID_ARGUMENTS=$? +if [ "$VALID_ARGUMENTS" != "0" ]; then + usage +fi + ARCH=$(/usr/bin/dpkg --print-architecture) -while getopts "h?vyi:acrbm:p" opt; do - case "$opt" in - h|\?) show_help; exit 0 ;; - v) P_Verbose=1 ;; - d) P_Debug=1 ;; - y) P_Yes=1 ;; - p) P_APT=1; P_DEB=1 ;; - c) P_CONFIG=1 ;; - r) P_RC=1 ;; - b) P_BINARY=1 ;; - i) P_Install=$OPTARG ;; - m) ARCH=$OPTARG ;; - z) P_ZSH=1 ;; - a) P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1; P_ZSH=1 ;; +echo "PARSED_ARGUMENTS is $PARSED_ARGUMENTS" +eval set -- "$PARSED_ARGUMENTS" +while : +do + case "$1" in + -h | --help) show_help ;; + -v) P_Verbose=1 ; shift ;; + -d | --debug) P_Debug=1 ; shift ;; + -y) P_Yes=1 ; shift ;; + -p) P_APT=1; P_DEB=1 ; shift ;; + -c) P_CONFIG=1 ; shift ;; + -r) P_RC=1 ; shift ;; + -b) P_BINARY=1 ; shift ;; + -i) P_Install="$2"; shift 2 ;; + -m | --arch) ARCH="$2" ; shift 2 ;; + -z) P_ZSH=1 ; shift ;; + -a) P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1; P_ZSH=1; shift ;; + # -- means the end of the arguments; drop this, and break out of the while loop + --) shift; break ;; + # If invalid options were passed, then getopt should have reported an error, + # which we checked as VALID_ARGUMENTS when getopt was called... + *) echo "Unexpected option: $1 - this should not happen." + usage ;; esac done +echo "Parameters remaining are: $@" + + ASK="\e[34m" INFO="\e[91m\e[1m" ADD="\e[32m\e[1m"