summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-10 12:53:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-10 12:54:19 +0200
commit7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c (patch)
tree8cc8e099f30f7d32fe7b17a9b6780784f446a8c3
parent8b1d11508e985cc2cd97a1d70d01574e78109569 (diff)
downloadapp.sh-7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c.tar.gz
app.sh-7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c.tar.bz2
app.sh-7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c.tar.xz
app.sh-7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c.zip
o Getting list-versions to work again.
o Allowing -n and -i before the method.
-rw-r--r--README.md4
-rwxr-xr-xapp60
2 files changed, 47 insertions, 17 deletions
diff --git a/README.md b/README.md
index 7ca5d3b..4373e16 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,8 @@ TODOs
* Concept: config. group, key and value.
* Scriptable
+* init.d support
+
Method Contract
---------------
@@ -26,4 +28,4 @@ Method Contract
* `APPSH_NAME`
* `APPSH_INSTANCE`
* `APPSH_METHOD`
-* `APPSH_PID_FILE`
+
diff --git a/app b/app
index 5fd0d11..b78d71b 100755
--- a/app
+++ b/app
@@ -502,12 +502,12 @@ method_list_versions() {
mode="parseable"
;;
\?)
- set_current_usage "Invalid option: -$OPTARG"
+ list_versions_usage "Invalid option: -$OPTARG"
;;
esac
done
- assert_is_instance set_current_usage "$name" "$instance"
+ assert_is_instance list_versions_usage "$name" "$instance" "no"
if [ $mode = "pretty" ]
then
@@ -566,6 +566,7 @@ method_set_current() {
exit 1
fi
+ rm -f $BASEDIR/$name/$instance/current
ln -s versions/$version/root $BASEDIR/$name/$instance/current
return 0
@@ -588,20 +589,47 @@ method_usage() {
. $BASEDIR/.app/lib/app-conf
-if [ $# -gt 0 ]
-then
+main() {
+ local method=""
+ local first
+
+ while getopts "n:i:" opt
+ do
+ case $opt in
+ n)
+ name=$OPTARG
+ first="$first -n $name"
+ shift
+ shift
+ OPTIND=1
+ ;;
+ i)
+ instance=$OPTARG
+ first="$first -i $instance"
+ shift
+ shift
+ OPTIND=1
+ ;;
+ \?)
+ echo "Invalid option: $OPTARG"
+ ;;
+ esac
+ done
+
method=$1
shift
-fi
-case "$method" in
- conf) method_conf $@ ;;
- install) method_install $@ ;;
- list) method_list $@ ;;
- list-versions) method_list_versions $@ ;;
- set-current) method_set_current $@ ;;
- start) method_start $@ ;;
- stop) method_stop $@ ;;
- *) method_usage $@ ;;
-esac
-exit $?
+ case "$method" in
+ conf) method_conf $first $@ ;;
+ install) method_install $first $@ ;;
+ list) method_list $first $@ ;;
+ list-versions) method_list_versions $first $@ ;;
+ set-current) method_set_current $first $@ ;;
+ start) method_start $first $@ ;;
+ stop) method_stop $first $@ ;;
+ *) method_usage $@ ;;
+ esac
+ exit $?
+}
+
+main $@