zshuper/modules/pluginmanager.zsh
2018-02-03 02:29:33 +02:00

57 lines
1.5 KiB
Bash

#
# Plugin manager "interface"
#
ZSPR_PLM_FUNCTIONS=(
__zspr_plm_init
__zspr_plm_load_plugins
__zspr_plm_install_plugin
__zspr_plm_update_plugins
__zspr_plm_has_plugin
)
# Initializes plugin manager
function __zspr_plm_init {
if [[ "${ZSPR_PLM_FUNCTIONS[1]}" = "__zspr_plm_init" ]]; then
echo "Plugin manager does not implement __zspr_plm_init"
else
"${ZSPR_PLM_FUNCTIONS[1]}" "${@}"
fi
}
# Loads plugins
function __zspr_plm_load_plugins {
if [[ "${ZSPR_PLM_FUNCTIONS[2]}" = "__zspr_plm_load_plugins" ]]; then
echo "Plugin manager does not implement __zspr_plm_load_plugins"
else
"${ZSPR_PLM_FUNCTIONS[2]}" "${@}"
fi
}
# Installs new plugin
function __zspr_plm_install_plugin {
if [[ "${ZSPR_PLM_FUNCTIONS[3]}" = "__zspr_plm_install_plugin" ]]; then
echo "Plugin manager does not implement __zspr_plm_install_plugin"
else
"${ZSPR_PLM_FUNCTIONS[3]}" "${@}"
fi
}
# Updates plugins
function __zspr_plm_update_plugins {
if [[ "${ZSPR_PLM_FUNCTIONS[4]}" = "__zspr_plm_update_plugins" ]]; then
echo "Plugin manager does not implement __zspr_plm_update_plugins"
else
"${ZSPR_PLM_FUNCTIONS[4]}" "${@}"
fi
}
# Returns wheter plugin is present or not
function __zspr_plm_has_plugin {
if [[ "${ZSPR_PLM_FUNCTIONS[5]}" = "__zspr_plm_has_plugin" ]]; then
echo "Plugin manager does not implement __zspr_plm_has_plugin"
else
"${ZSPR_PLM_FUNCTIONS[5]}" "${@}"
fi
}