From 7a8c58e530cea4d2659ad1ef9a6288bbc8fd298c Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 10 Oct 2012 12:53:50 +0200 Subject: o Getting list-versions to work again. o Allowing -n and -i before the method. --- README.md | 4 +++- app | 60 ++++++++++++++++++++++++++++++++++++++++++++---------------- 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 $@ -- cgit v1.2.3