diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-10-13 00:18:25 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-10-13 00:18:25 +0200 |
commit | eb61b509dd39ffdd399ae0c36f027af28283078e (patch) | |
tree | 31bd8e6c5a4538b4a573052a3802d4fc890c2923 /.app/lib/app-app | |
parent | 0ddf6b37b56423ec8ca72ff67c825d2503a1ff5f (diff) | |
download | app.sh-eb61b509dd39ffdd399ae0c36f027af28283078e.tar.gz app.sh-eb61b509dd39ffdd399ae0c36f027af28283078e.tar.bz2 app.sh-eb61b509dd39ffdd399ae0c36f027af28283078e.tar.xz app.sh-eb61b509dd39ffdd399ae0c36f027af28283078e.zip |
o Better help output.
o Better validation of argument for install.
Diffstat (limited to '.app/lib/app-app')
-rw-r--r-- | .app/lib/app-app | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/.app/lib/app-app b/.app/lib/app-app index 073a8ba..0be0bb5 100644 --- a/.app/lib/app-app +++ b/.app/lib/app-app @@ -74,8 +74,8 @@ method_install_usage() { } method_install() { - local name="$1" - local instance="$2" + local name="$1"; shift + local instance="$2"; shift local version local resolver local url @@ -83,7 +83,10 @@ method_install() { local artifactId local zip_file - shift 2 + if [ $# -eq 0 ] + then + method_install_usage + fi while getopts "n:i:v:r:u:" opt do @@ -109,6 +112,16 @@ method_install() { esac done + if [ -z "$resolver" ] + then + method_install_usage "Missing required option: -r resolver" + fi + + if [ -z "$url" ] + then + method_install_usage "Missing required option: -u url" + fi + case "$resolver" in maven) url=`echo $url | tr ":" " "`; set -- $url @@ -233,10 +246,15 @@ method_set_current_usage() { } method_set_current() { - local name - local instance + local name="$1"; shift + local instance="$2"; shift local version + if [ $# -eq 0 ] + then + method_set_current_usage + fi + while getopts "n:i:v:" opt do case $opt in @@ -292,6 +310,8 @@ method_list_usage() { } method_list() { + local filter_name="$1"; shift + local instance="$2"; shift local mode="pretty" local vars local filter_name @@ -336,16 +356,21 @@ method_list_versions_usage() { fi echo "usage: list-versions -n name -i instance [-P]" >&2 - echo " -P - parseable output" >&2 + echo " -P - parsable output" >&2 exit 1 } method_list_versions() { - local name - local instance + local filter_name="$1"; shift + local instance="$2"; shift local version local mode="pretty" + if [ $# -eq 0 ] + then + method_list_versions_usage + fi + while getopts "n:i:P" opt do case $opt in @@ -400,7 +425,7 @@ method_app() { shift 2 - if [ $# -gt 2 ] + if [ $# -gt 0 ] then method=$1 shift @@ -411,7 +436,7 @@ method_app() { list) method_list "$name" "$instance" "$@" ;; list-versions) method_list_versions "$name" "$instance" "$@" ;; set-current) method_set_current "$name" "$instance" "$@" ;; - *) method_app_usage ;; + *) method_app_usage "Unknown method $method" ;; esac exit $? } |