aboutsummaryrefslogtreecommitdiff
path: root/inception
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-16 10:37:24 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-16 10:37:24 -0300
commit1c8afde62ea550c6db0de80d1873feff5e3c7038 (patch)
treebc5bafd441373fd792ebbf2eb346b0f4dad64fa9 /inception
parent9a509b083bae8f995ce8a4eb3f708b8a54d0b960 (diff)
downloadapps-1c8afde62ea550c6db0de80d1873feff5e3c7038.tar.gz
apps-1c8afde62ea550c6db0de80d1873feff5e3c7038.tar.bz2
Inception: split into functions
Diffstat (limited to 'inception')
-rwxr-xr-xinception59
1 files changed, 50 insertions, 9 deletions
diff --git a/inception b/inception
index db44ca2..8edc8e7 100755
--- a/inception
+++ b/inception
@@ -7,10 +7,14 @@
BASENAME="`basename $0`"
DIRNAME="$(cd `dirname $0` &> /dev/null && pwd)"
-# Main
-if [ -z "$1" ]; then
+# Usage
+function inception_usage {
echo "usage: $BASENAME <action> [options]"
-elif [ "$1" == "init" ]; then
+ exit 1
+}
+
+# Initialize
+function inception_init {
(
cd $DIRNAME
@@ -39,7 +43,10 @@ elif [ "$1" == "init" ]; then
echo ""
echo "Please manually verify dotfiles version and tag from the above output."
echo "If everything is fine, proceed running this command again with the 'load' parameter."
-elif [ "$1" == "load" ]; then
+}
+
+# Load
+function inception_load {
(
cd $DIRNAME
@@ -64,12 +71,18 @@ elif [ "$1" == "load" ]; then
)
echo "Done. Logout and login again to apply all changes."
-elif [ "$1" == "install" ]; then
+}
+
+# Install
+function inception_install {
# We could just do that, but we shall make sure that code was verified
#$0 init
#$0 load
echo "Please README!"
-elif [ "$1" == "deploy" ]; then
+}
+
+# Deploy
+function inception_deploy {
if [ ! -z "$2" ]; then
REMOTE="$2"
MODULES="`$DIRNAME/metadot/metadot installed | xargs`"
@@ -93,10 +106,38 @@ elif [ "$1" == "deploy" ]; then
##### END REMOTE SCRIPT #######
EOF
fi
-elif [ "$1" == "version" ]; then
+}
+
+# Version information
+function inception_version {
( cd $DIRNAME && git log --show-signature -n 1 )
-elif [ "$1" == "fetch" ]; then
+}
+
+# Fetch
+function inception_fetch {
( cd $DIRNAME && git fetch --all && git log -n 1 --branches=origin/master )
-elif [ "$1" == "merge" ]; then
+}
+
+# Merge
+function inception_merge {
( cd $DIRNAME && git merge origin/master && git submodule update --init --recursive )
+}
+
+# Main
+if [ -z "$1" ]; then
+ inception_usage
+elif [ "$1" == "init" ]; then
+ inception_init
+elif [ "$1" == "load" ]; then
+ inception_load $*
+elif [ "$1" == "install" ]; then
+ inception_install $*
+elif [ "$1" == "deploy" ]; then
+ inception_deploy $*
+elif [ "$1" == "version" ]; then
+ inception_version
+elif [ "$1" == "fetch" ]; then
+ inception_fetch
+elif [ "$1" == "merge" ]; then
+ inception_merge
fi