From: Silvio Rhatto Date: Thu, 16 Mar 2017 13:37:24 +0000 (-0300) Subject: Inception: split into functions X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=1c8afde62ea550c6db0de80d1873feff5e3c7038;p=rhatto%2Fapps.git Inception: split into functions --- 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 [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