aboutsummaryrefslogtreecommitdiffstats
path: root/mayor/bin/help.sh
blob: e983ccd3370b427d6ab9cab6a4c3d91fe0834dbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

OPT_SPEC="hf::"
LONG_OPT_SPEC="help,file:,f::"
PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@")
OPTIONS_RET=$?
eval set -- "$PARSED_OPTIONS"

help_usage() {
    print_help;
    echo -e "\nHELP használata: mayor help [parancs]\n\n"
}

if [ $OPTIONS_RET -ne 0 ] || [ $# -le 1 ]; then  help_usage; exit; fi

while [ $# -ge 1 ]; do
    case $1 in
        --help | -h )           help_usage
                                exit
                                ;;

        --file | -f )           shift
                                FILE="$1"
				echo "FILE: $FILE"
                                ;;

        -- )                    shift
				break
                                ;;

        * )                     echo "HIBA: ismeretlen opció: $1" # ide elvileg sose jutunk, mert a getopts már kiszűrte a hibás paramétereket...
                                exit
                                ;;
    esac
    shift
done

while [ $# -ge 1 ]; do
    echo -e "\n---------- HELP: $1 ----------\n"
    if [[ ! "${CMDS[*]}" =~ .*$1.* ]]; then
	echo -e "Ismeretlen parancs: $1"
	#print_help
    else
	. ./$1.sh --help
    fi
    shift
done