]> gitweb.fluxo.info Git - rhatto/apps.git/commitdiff
Inception: split into functions
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 16 Mar 2017 13:37:24 +0000 (10:37 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 16 Mar 2017 13:37:24 +0000 (10:37 -0300)
inception

index db44ca28ed2e13d18e43f9fe9cb5672cdc9c9921..8edc8e79e478633d23de327bc5383107b279f7a7 100755 (executable)
--- 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