2023-11-16 07:20:27 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
NULIB_NO_IMPORT_DEFAULTS=1
|
|
|
|
source "$(dirname -- "$0")/../load.sh" || exit 1
|
|
|
|
|
|
|
|
LIST_FUNCS=
|
2023-11-17 06:46:07 +04:00
|
|
|
SHOW_MODULE=
|
2023-11-16 07:20:27 +04:00
|
|
|
SHOW_FUNCS=()
|
|
|
|
function nulib__define_functions() {
|
|
|
|
function nulib_check_loaded() {
|
|
|
|
local module
|
|
|
|
for module in "${NULIB_LOADED_MODULES[@]}"; do
|
|
|
|
[ "$module" == "$1" ] && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
function module:() {
|
|
|
|
if [ -n "$LIST_FUNCS" ]; then
|
2023-11-17 11:11:03 +04:00
|
|
|
esection "@$1: $2"
|
2023-11-16 07:20:27 +04:00
|
|
|
fi
|
2023-11-17 06:46:07 +04:00
|
|
|
local module
|
|
|
|
SHOW_MODULE=
|
|
|
|
for module in "${SHOW_FUNCS[@]}"; do
|
|
|
|
if [ "$module" == "@$1" ]; then
|
|
|
|
SHOW_MODULE=1
|
|
|
|
fi
|
|
|
|
done
|
2023-11-16 07:20:27 +04:00
|
|
|
NULIB_MODULE="$1"
|
|
|
|
if ! nulib_check_loaded "$1"; then
|
|
|
|
NULIB_LOADED_MODULES+=("$1")
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function function:() {
|
|
|
|
if [ -n "$LIST_FUNCS" ]; then
|
2023-11-17 11:11:03 +04:00
|
|
|
eecho "$1"
|
2023-11-17 06:46:07 +04:00
|
|
|
elif [ -n "$SHOW_MODULE" ]; then
|
2023-11-17 11:11:03 +04:00
|
|
|
eecho "$COULEUR_BLEUE>>> $1 <<<$COULEUR_NORMALE"
|
2023-11-17 06:46:07 +04:00
|
|
|
eecho "$2"
|
2023-11-16 07:20:27 +04:00
|
|
|
else
|
|
|
|
local func
|
|
|
|
for func in "${SHOW_FUNCS[@]}"; do
|
|
|
|
if [ "$func" == "$1" ]; then
|
|
|
|
esection "$1"
|
|
|
|
eecho "$2"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
require: DEFAULTS
|
|
|
|
|
|
|
|
modules=()
|
|
|
|
args=(
|
|
|
|
"afficher l'aide d'une fonction nulib"
|
2023-11-17 06:46:07 +04:00
|
|
|
"FUNCTIONS|@MODULES..."
|
2023-11-16 07:20:27 +04:00
|
|
|
-m:,--module: modules "charger des modules supplémentaires"
|
|
|
|
-l,--list LIST_FUNCS=1 "lister les fonctions pour lesquelles une aide existe"
|
|
|
|
)
|
|
|
|
parse_args "$@"; set -- "${args[@]}"
|
|
|
|
|
|
|
|
for func in "$@"; do
|
|
|
|
SHOW_FUNCS+=("$func")
|
|
|
|
done
|
|
|
|
|
|
|
|
NULIB_LOADED_MODULES=(nulib)
|
|
|
|
require: DEFAULTS
|
|
|
|
for module in "${modules[@]}"; do
|
|
|
|
require: "$module"
|
|
|
|
done
|