Pass arg $0 to module_main
This commit is contained in:
@@ -101,11 +101,11 @@ function configure_system() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUsage() {
|
function getUsage() {
|
||||||
local text
|
local cmdName=$1 text=''
|
||||||
read -r -d '' text <<- USAGE
|
read -r -d '' text <<- USAGE
|
||||||
Usage:
|
Usage:
|
||||||
$0 show-questions
|
$cmdName show-questions
|
||||||
$0 [-v] [-d FILE] --hostname NAME --timezone ZONE
|
$cmdName [-v] [-d FILE] --hostname NAME --timezone ZONE
|
||||||
|
|
||||||
Set energy, basic network and host preferences.
|
Set energy, basic network and host preferences.
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ function getUsage() {
|
|||||||
-d FILE, --logfile FILE Print log message to logfile instead of stdout.
|
-d FILE, --logfile FILE Print log message to logfile instead of stdout.
|
||||||
-v, --verbose Be more verbose.
|
-v, --verbose Be more verbose.
|
||||||
----
|
----
|
||||||
$0 0.1.0
|
$cmdName 0.1.0
|
||||||
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
|
||||||
@@ -125,5 +125,5 @@ function getUsage() {
|
|||||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
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 }
|
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}"
|
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
||||||
module_main "$@"
|
module_main $0 "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ function showQuestions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function module_main() {
|
function module_main() {
|
||||||
|
local cmdName=${1:t}
|
||||||
|
shift
|
||||||
autoloadZShLib || return
|
autoloadZShLib || return
|
||||||
checkPrerequisites || return
|
checkPrerequisites || return
|
||||||
eval "`getUsage | docopts -f -V - -h - : "$@"`"
|
eval "`getUsage $cmdName | docopts -f -V - -h - : "$@"`"
|
||||||
[ $# -le 1 ] && return
|
[ $# -lt 1 ] && return
|
||||||
configureLogging
|
configureLogging
|
||||||
[ "${show_questions}" = true ] && { showQuestions; return }
|
[ "${show_questions}" = true ] && { showQuestions; return }
|
||||||
configure_system
|
configure_system
|
||||||
|
|||||||
Reference in New Issue
Block a user