]> arthur.barton.de Git - ax-zsh.git/blobdiff - bin/axzshctl
axzshctl: Implement "upgrade" command
[ax-zsh.git] / bin / axzshctl
index 82fb065bd858e69fa01fae5b9709aa30de870270..20ebe115fb4f69b05696a8bfd0ed351dadf7baff 100755 (executable)
@@ -37,6 +37,9 @@ function Usage {
        echo "  enable-default-plugins"
        echo "    Enable all default plugins."
        echo
+       echo "  upgrade"
+       echo "    Upgrade AX-ZSH installation (requires Git)."
+       echo
        exit 2
 }
 
@@ -104,6 +107,20 @@ function EnableDefaultPlugins {
        return $?
 }
 
+function UpgradeAXZSH {
+       if [[ $+commands[git] -eq 0 ]]; then
+               ax_msg 2 "The git(1) command is not available!"
+               return 1
+       fi
+       if [[ ! -d "$AXZSH/.git" ]]; then
+               ax_msg 2 "AX-ZSH seems not to be installed using Git. Can't upgrade!"
+               return 1
+       fi
+
+       ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..."
+       ( cd "$AXZSH" && git pull --ff-only )
+}
+
 NAME="$(basename "$0")"
 
 [[ $# -gt 0 ]] || Usage
@@ -138,6 +155,10 @@ case "$cmd" in
                [[ $# -eq 0 ]] || Usage
                EnableDefaultPlugins
                ;;
+       "upgrade")
+               [[ $# -eq 0 ]] || Usage
+               UpgradeAXZSH
+               ;;
        *)
                Usage
 esac