nulib/bin/nlman

70 lines
1.7 KiB
Bash
Executable File

#!/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=
SHOW_MODULE=
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
esection "@$1: $2"
fi
local module
SHOW_MODULE=
for module in "${SHOW_FUNCS[@]}"; do
if [ "$module" == "@$1" ]; then
SHOW_MODULE=1
fi
done
NULIB_MODULE="$1"
if ! nulib_check_loaded "$1"; then
NULIB_LOADED_MODULES+=("$1")
fi
}
function function:() {
if [ -n "$LIST_FUNCS" ]; then
eecho "$1"
elif [ -n "$SHOW_MODULE" ]; then
eecho "$COULEUR_BLEUE>>> $1 <<<$COULEUR_NORMALE"
eecho "$2"
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"
"FUNCTIONS|@MODULES..."
-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