From 2c731c0434583dc43e02b7c9db216e2e9e09fd7c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 18 May 2018 09:08:19 -0300 Subject: Better action handling --- infection | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'infection') diff --git a/infection b/infection index 8572a6d..def25ca 100755 --- a/infection +++ b/infection @@ -8,6 +8,7 @@ BASENAME="`basename $0`" EXCLUDES="--exclude=local --exclude=stowpkg/tree" DATE="`date +%Y%m%d%I%M%S`" BACKUPS="$HOME/.backups/$DATE" +ACTION="$1" # Make sure we're running git directly and not any existing wrapper GIT="/usr/bin/git" @@ -46,9 +47,11 @@ function infection_init { cd $DIRNAME &> /dev/null - echo "Initializing submodules..." - $GIT submodule sync --recursive - $GIT submodule update --init --recursive + if [ "$ACTION" == "fetch" ] && [ "$ACTION" == "merge" ]; then + echo "Initializing submodules..." + $GIT submodule sync --recursive + $GIT submodule update --init --recursive + fi # Convert to new dotfiles layout # @@ -201,22 +204,22 @@ fi infection_init # Main -if [ "$1" == "load" ]; then +if [ "$ACTION" == "load" ]; then infection_load $* -#elif [ "$1" == "init" ]; then +#elif [ "$ACTION" == "init" ]; then # infection_init -elif [ "$1" == "install" ]; then +elif [ "$ACTION" == "install" ]; then infection_install $* -elif [ "$1" == "deploy" ]; then +elif [ "$ACTION" == "deploy" ]; then infection_deploy $* -elif [ "$1" == "version" ]; then +elif [ "$ACTION" == "version" ]; then infection_version -elif [ "$1" == "fetch" ]; then +elif [ "$ACTION" == "fetch" ]; then infection_fetch -elif [ "$1" == "merge" ]; then +elif [ "$ACTION" == "merge" ]; then infection_merge -elif [ "$1" == "status" ]; then +elif [ "$ACTION" == "status" ]; then infection_status -elif [ "$1" != "init" ]; then +elif [ "$ACTION" != "init" ]; then infection_usage fi -- cgit v1.2.3