diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-10-07 19:24:51 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-10-07 19:24:51 +0200 |
commit | 1af970e428fcca786a579b85e9199f8cd7efa316 (patch) | |
tree | 7996ac2faf9f5941bb50a075391c4c427eed9748 | |
parent | bdd53c4ba364efd68b7c7ec9132004bd494050d4 (diff) | |
download | app.sh-1af970e428fcca786a579b85e9199f8cd7efa316.tar.gz app.sh-1af970e428fcca786a579b85e9199f8cd7efa316.tar.bz2 app.sh-1af970e428fcca786a579b85e9199f8cd7efa316.tar.xz app.sh-1af970e428fcca786a579b85e9199f8cd7efa316.zip |
o Adding a -P option to 'list' to give more parsable output.
-rwxr-xr-x | app | 57 |
1 files changed, 52 insertions, 5 deletions
@@ -350,17 +350,61 @@ method_stop() { method_list() { - printf "%-20s %-20s %-20s\n" "Name" "Instance" "Version" + local mode="pretty" + + while getopts "P" opt + do + case $opt in + P) + mode="parseable" + shift + ;; + \?) + install_usage "Invalid option: -$OPTARG" + ;; + esac + done if [ ! -r $BASEDIR/.app/var/list ] then return fi - sort $BASEDIR/.app/var/list | (export IFS=:; while read instance name version - do - printf "%-20s %-20s %-20s\n" "$name" "$instance" "$version" - done) + x="$@" + if [ -z "$x" ] + then + vars="name instance version" + else + vars="$@" + fi + + if [ $mode = "pretty" ] + then + printf "%-20s %-20s %-20s\n" "Name" "Instance" "Version" + fi + + sort $BASEDIR/.app/var/list | ( + IFS=:; while read instance name version + do + if [ $mode = "pretty" ] + then + printf "%-20s %-20s %-20s\n" "$name" "$instance" "$version" + else + line="" + IFS=" "; for var in $vars + do + eval v=\$$var + if [ -z "$line" ] + then + line="$line$v" + else + line="$line:$v" + fi + done + echo $line + fi + done + ) } method_usage() { @@ -369,6 +413,9 @@ method_usage() { echo "Available methods:" >&2 echo " install - Installs an application" >&2 echo " list - List all installed applications" >&2 + echo " start - Starts an applications" >&2 + echo " stop - Stops an applications" >&2 + echo " conf - Application configuration management" >&2 echo "" >&2 echo "Run '$0 <method>' to get more help" >&2 } |