mirror of
https://github.com/m8tin/cis.git
synced 2026-06-02 14:56:58 +02:00
better self explain
This commit is contained in:
+23
-4
@@ -203,8 +203,6 @@ function base.filterComments(){
|
||||
return 1
|
||||
}
|
||||
|
||||
# Funktionen von Module, die mit dieser Funktion geladen werden, behalten ihren Name.
|
||||
# Deshalb dürfen solche Funktionen auch nicht per '→ FunktionsName' aufgerufen werden!
|
||||
function base.loadModule() {
|
||||
local _MODULENAME _MODULEFULLNAME
|
||||
_MODULENAME="${1:?"Function base.loadModule(): Missing parameter MODULENAME."}"
|
||||
@@ -257,6 +255,23 @@ function base.log() {
|
||||
esac
|
||||
}
|
||||
|
||||
function base.printEnvironment() {
|
||||
# Check precondition
|
||||
[[ "${CIS[SET]:+isset}" != "isset" ]] \
|
||||
&& declare -A -g CIS=([SET]=unprepared) \
|
||||
&& prepare.setCIS
|
||||
|
||||
[[ "${CIS[SET]:+isset}" != "isset" ]] \
|
||||
&& return 1
|
||||
|
||||
echo "Content of array CIS:"
|
||||
echo "---------------------"
|
||||
for _KEY in "${!CIS[@]}"; do
|
||||
printf " %s\n" "CIS[${_KEY}]: ${CIS[${_KEY}]}\n"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
function base.printModuleFunctions() {
|
||||
local _MODULENAME
|
||||
_MODULENAME="${1:?"Function base.printModuleFunctions(): Missing parameter MODULENAME."}"
|
||||
@@ -323,14 +338,18 @@ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
echo "FAILURE: you are using this module 'base.sh' in a wrong way."
|
||||
echo " It is intended as a utility library and should not be called directly."
|
||||
echo
|
||||
echo "Usage: Call the base module at the beginning of your script e.g. like this:"
|
||||
echo "Usage: Call the base module at the beginning of your script, like this:"
|
||||
echo "-----------------------------------------------------------------------"
|
||||
echo
|
||||
echo '#!/bin/bash'
|
||||
echo 'source /cis/core/base.module.sh'
|
||||
echo
|
||||
echo
|
||||
base.printEnvironment
|
||||
echo
|
||||
echo "Now you can use the functions provided by this module inside your script:"
|
||||
echo "-------------------------------------------------------------------------"
|
||||
declare -F | grep "base." | cut -d" " -f3
|
||||
declare -F | grep "base." | cut -d" " -f3 | xargs -n1 printf " %s\n"
|
||||
exit 1
|
||||
else
|
||||
# If not exists, define a global array 'COLOR'
|
||||
|
||||
Reference in New Issue
Block a user