Add module_main to lib.sh
This commit is contained in:
@@ -92,10 +92,21 @@ function configureLoginWindow() {
|
||||
lop success 'done'
|
||||
}
|
||||
|
||||
function main() {
|
||||
autoloadZShLib || return
|
||||
checkPrerequisites || return
|
||||
eval "`docopts -f -V - -h - : "$@" <<- USAGE
|
||||
function configure_system() {
|
||||
quitSystemPreferences
|
||||
configureComputerHostname
|
||||
configureBasicSystem
|
||||
configurePowerManagement
|
||||
configureLoginWindow
|
||||
|
||||
lop info 'Configuring global umask'
|
||||
launchctl config user umask 027
|
||||
}
|
||||
|
||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
||||
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
|
||||
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
||||
module_main "$@" <<- USAGE
|
||||
Usage:
|
||||
$0 show-questions
|
||||
$0 [-v] [-d FILE] --hostname NAME --timezone ZONE
|
||||
@@ -111,23 +122,5 @@ function main() {
|
||||
$0 0.1.0
|
||||
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
|
||||
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
|
||||
USAGE`"
|
||||
[ $# -eq 0 ] && return
|
||||
configureLogging
|
||||
[ "${show_questions}" = true ] && { showQuestions; return }
|
||||
|
||||
quitSystemPreferences
|
||||
configureComputerHostname
|
||||
configureBasicSystem
|
||||
configurePowerManagement
|
||||
configureLoginWindow
|
||||
|
||||
lop info 'Configuring global umask'
|
||||
launchctl config user umask 027
|
||||
}
|
||||
|
||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
||||
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
|
||||
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
||||
main "$@"
|
||||
USAGE
|
||||
fi
|
||||
|
||||
@@ -25,3 +25,13 @@ function checkCommands() {
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function module_main() {
|
||||
autoloadZShLib || return
|
||||
checkPrerequisites || return
|
||||
eval "`docopts -f -V - -h - : "$@"`"
|
||||
[ $# -le 1 ] && return
|
||||
configureLogging
|
||||
[ "${show_questions}" = true ] && { showQuestions; return }
|
||||
configure_system
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user