mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
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:
32
src/actions/git.sh
Normal file
32
src/actions/git.sh
Normal 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
32
src/actions/link.sh
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user