From 0c6cc19bc1e091f41353f8cacb0b84f662008435 Mon Sep 17 00:00:00 2001 From: Rezart Qelibari Date: Tue, 26 Apr 2022 04:06:18 +0200 Subject: [PATCH] Add hooks to lib/module_main --- modules/lib.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/lib.sh b/modules/lib.sh index 6fe723a..3eb3fd1 100644 --- a/modules/lib.sh +++ b/modules/lib.sh @@ -79,25 +79,29 @@ function showQuestions() { } function module_main() { - local cmdName=${1:t} + local cmdPath=${1} cmdName=${1:t} hookBag=() local -A traps=() + preCommandNameHook "$@" || return shift autoloadZShLib || return + preHelpHook "$@" || return checkHelpPrerequisites || return configureLogging trap 'traps call int; return 70' INT trap 'traps call term; return 80' TERM trap 'traps call exit' EXIT eval "`getUsage $cmdName | docopts -f -V - -h - : "$@"`" + preQuestionHook "$@" || return checkQuestionsPrerequisites || return [ "${show_questions}" = true ] && { showQuestions; return } + preExecHook "$@" || return checkExecPrerequisites || return configure_system } function { 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 $_() {} done }