aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-13 00:18:25 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-13 00:18:25 +0200
commiteb61b509dd39ffdd399ae0c36f027af28283078e (patch)
tree31bd8e6c5a4538b4a573052a3802d4fc890c2923
parent0ddf6b37b56423ec8ca72ff67c825d2503a1ff5f (diff)
downloadapp.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.
-rw-r--r--.app/lib/app-app45
-rwxr-xr-xapp1
-rw-r--r--docs/README.md2
3 files changed, 38 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 $?
}
diff --git a/app b/app
index c02d417..45adaee 100755
--- a/app
+++ b/app
@@ -23,6 +23,7 @@ method_usage() {
echo "Run $0 -h <group> for more help" >&2
}
+. $BASEDIR/.app/lib/app-common
. $BASEDIR/.app/lib/app-app
. $BASEDIR/.app/lib/app-conf
. $BASEDIR/.app/lib/app-operate
diff --git a/docs/README.md b/docs/README.md
index 7e2a5f6..8845059 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -35,6 +35,8 @@ TODOs
* init.d support
+* Support -h for all applicable methods to show the help/usage.
+
Commands
--------