Call getUsage after checking prerequisites in lib
This commit is contained in:
@@ -100,16 +100,15 @@ function configure_system() {
|
|||||||
launchctl config user umask 027
|
launchctl config user umask 027
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
function getUsage() {
|
||||||
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 }
|
local text
|
||||||
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
read -r -d '' text <<- USAGE
|
||||||
module_main "$@" <<- USAGE
|
|
||||||
Usage:
|
Usage:
|
||||||
$0 show-questions
|
$0 show-questions
|
||||||
$0 [-v] [-d FILE] --hostname NAME --timezone ZONE
|
$0 [-v] [-d FILE] --hostname NAME --timezone ZONE
|
||||||
|
|
||||||
Set energy, basic network and host preferences.
|
Set energy, basic network and host preferences.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--hostname NAME Set NAME as current host's host name.
|
--hostname NAME Set NAME as current host's host name.
|
||||||
--timezone ZONE Set ZONE as current host's timezone [default: Europe/Berlin].
|
--timezone ZONE Set ZONE as current host's timezone [default: Europe/Berlin].
|
||||||
@@ -120,4 +119,11 @@ if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
|||||||
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
|
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
|
||||||
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
|
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
|
||||||
USAGE
|
USAGE
|
||||||
|
print ${text}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function showQuestions() {
|
|||||||
function module_main() {
|
function module_main() {
|
||||||
autoloadZShLib || return
|
autoloadZShLib || return
|
||||||
checkPrerequisites || return
|
checkPrerequisites || return
|
||||||
eval "`docopts -f -V - -h - : "$@"`"
|
eval "`getUsage | docopts -f -V - -h - : "$@"`"
|
||||||
[ $# -le 1 ] && return
|
[ $# -le 1 ] && return
|
||||||
configureLogging
|
configureLogging
|
||||||
[ "${show_questions}" = true ] && { showQuestions; return }
|
[ "${show_questions}" = true ] && { showQuestions; return }
|
||||||
|
|||||||
Reference in New Issue
Block a user