#!/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_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" fi NULIB_MODULE="$1" if ! nulib_check_loaded "$1"; then NULIB_LOADED_MODULES+=("$1") fi } function function:() { if [ -n "$LIST_FUNCS" ]; then estep "$1" 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" #"usage" -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