Add hooks to lib/module_main

This commit is contained in:
Rezart Qelibari
2022-04-26 04:06:18 +02:00
parent 20a9d88385
commit 0c6cc19bc1

View File

@@ -79,25 +79,29 @@ function showQuestions() {
} }
function module_main() { function module_main() {
local cmdName=${1:t} local cmdPath=${1} cmdName=${1:t} hookBag=()
local -A traps=() local -A traps=()
preCommandNameHook "$@" || return
shift shift
autoloadZShLib || return autoloadZShLib || return
preHelpHook "$@" || return
checkHelpPrerequisites || return checkHelpPrerequisites || return
configureLogging configureLogging
trap 'traps call int; return 70' INT trap 'traps call int; return 70' INT
trap 'traps call term; return 80' TERM trap 'traps call term; return 80' TERM
trap 'traps call exit' EXIT trap 'traps call exit' EXIT
eval "`getUsage $cmdName | docopts -f -V - -h - : "$@"`" eval "`getUsage $cmdName | docopts -f -V - -h - : "$@"`"
preQuestionHook "$@" || return
checkQuestionsPrerequisites || return checkQuestionsPrerequisites || return
[ "${show_questions}" = true ] && { showQuestions; return } [ "${show_questions}" = true ] && { showQuestions; return }
preExecHook "$@" || return
checkExecPrerequisites || return checkExecPrerequisites || return
configure_system configure_system
} }
function { function {
local name local name
for name in getQuestionsPrerequisites getExecPrerequisites getQuestions getUsage; do for name in preCommandNameHook preHelpHook preQuestionHook preExecHook getQuestionsPrerequisites getExecPrerequisites getQuestions getUsage; do
whence ${name} >&! /dev/null || function $_() {} whence ${name} >&! /dev/null || function $_() {}
done done
} }