aboutsummaryrefslogtreecommitdiff
path: root/libexec/app-resolver-file
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-02-04 17:38:32 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-02-04 17:38:32 +0100
commit32826f3c989e63f53510a9bdccd1855a9ae00636 (patch)
tree8f16fc8e7cb218a508bf58ee959ad7a978d6721f /libexec/app-resolver-file
parentfc7a39f18241ab731d87f7a80ef2bf36151dc184 (diff)
downloadapp.sh-32826f3c989e63f53510a9bdccd1855a9ae00636.tar.gz
app.sh-32826f3c989e63f53510a9bdccd1855a9ae00636.tar.bz2
app.sh-32826f3c989e63f53510a9bdccd1855a9ae00636.tar.xz
app.sh-32826f3c989e63f53510a9bdccd1855a9ae00636.zip
o Adding a file resolver.
o Getting the IT to work on windows.
Diffstat (limited to 'libexec/app-resolver-file')
-rwxr-xr-xlibexec/app-resolver-file94
1 files changed, 94 insertions, 0 deletions
diff --git a/libexec/app-resolver-file b/libexec/app-resolver-file
new file mode 100755
index 0000000..6282b83
--- /dev/null
+++ b/libexec/app-resolver-file
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+set -e
+set -u
+
+APPSH_HOME=$(cd $(dirname "$0")/.. && pwd)
+
+. $APPSH_HOME/lib/common
+# HEADER END
+
+usage_text() {
+ echo "usage: $usage_app init <file>"
+ echo "usage: $usage_app resolve-version"
+ echo "usage: $usage_app download-version -v <version> -f <download target>"
+}
+
+init() {
+ while getopts "r:" opt
+ do
+ case $opt in
+ r)
+ app-conf set maven.repo "$OPTARG"
+ shift 2
+ OPTIND=1
+ ;;
+ *)
+ usage "Invalid option: $OPTARG"
+ ;;
+ esac
+ done
+
+ local file=${1-}
+
+ if [[ ! -r "$file" ]]
+ then
+ fatal "Can't read file: $file"
+ fi
+
+ app-conf set file.path "$file"
+}
+
+resolve_version() {
+ path=$(app-conf get file.path)
+
+ local s=$(stat -c %Z $path)
+
+ app-conf set app.version "$s"
+}
+
+download_version() {
+ target=""
+ while getopts "v:f:" opt
+ do
+ case $opt in
+ v)
+ # Ignored
+ ;;
+ f)
+ target="$OPTARG"
+ ;;
+ *)
+ usage "Invalid option: $OPTARG"
+ ;;
+ esac
+ done
+
+ if [[ $target == "" ]]
+ then
+ usage
+ fi
+
+ path=$(app-conf get file.path)
+
+ ln -s "$path" "$target"
+}
+
+command="$1"; shift
+
+case "$command" in
+ init)
+ init "$@"
+ ;;
+ resolve-version)
+ resolve_version
+ ;;
+ download-version)
+ download_version "$@"
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit 0