Change how plugins/actions work a bit

This includes both how they detect what the current
mode (install/uninstall/cleanup/etc) is, and also forces them to
register themselves with Dotify. The registration will be used for
running pre/post hooks.
This commit is contained in:
2014-03-08 13:26:42 +00:00
parent 3e6f1b02c3
commit 8fa09ea3c3
6 changed files with 73 additions and 34 deletions

32
src/actions/git.sh Normal file
View File

@@ -0,0 +1,32 @@
# Register git action
dotify-register-action "git"
# Git action.
dotify-action-git() {
local mode="$1"
! local valid_mode="$(command -v "dotify-action-git-do-${mode}")"
if [ -n "$valid_mode" ]; then
shift 1
dotify-action-git-do-${mode} $@
fi
}
dotify-action-git-do-install() {
echo "git install: $@"
}
dotify-action-git-do-uninstall() {
echo "git uninstall: $@"
}
dotify-action-git-do-cleanup() {
echo "git cleanup: $@"
}
dotify-action-git-post-run() {
if [ "$1" == "cleanup" ]; then
shift 1
dotify-action-link-do-cleanup $@
fi
}

32
src/actions/link.sh Normal file
View File

@@ -0,0 +1,32 @@
# Register link action.
dotify-register-action "link"
# Link action.
dotify-action-link() {
local mode="$1"
! local valid_mode="$(command -v "dotify-action-link-do-${mode}")"
if [ -n "$valid_mode" ]; then
shift 1
dotify-action-link-do-${mode} $@
fi
}
dotify-action-link-do-install() {
echo "link install: $@"
}
dotify-action-link-do-uninstall() {
echo "link uninstall: $@"
}
dotify-action-link-do-cleanup() {
echo "link cleanup: $@"
}
dotify-action-link-post-run() {
if [ "$1" == "cleanup" ]; then
shift 1
dotify-action-link-do-cleanup $@
fi
}