--- trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 12:46:03 2391 +++ trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 12:54:43 2392 @@ -6,10 +6,23 @@ # common dialog boxes messagebox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" [[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" @@ -28,10 +41,23 @@ inputbox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" [[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" @@ -48,10 +74,23 @@ passwordbox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" [[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" @@ -69,10 +108,23 @@ gaugebox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" [[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" @@ -88,10 +140,23 @@ yesnobox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" [[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given"