-
Notifications
You must be signed in to change notification settings - Fork 223
/
Copy pathcli_show
79 lines (56 loc) · 1.82 KB
/
cli_show
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# shellcheck shell=bash
# ``````````````````````````````````````````````````````````````````````````````
# Function name: cli_show()
#
# Description:
# Show help in cli.
#
# Usage:
# cli_show
#
# Examples:
# cli_show
#
function cli_show() {
# shellcheck disable=SC2034
local _FUNCTION_ID="cli_show"
local _STATE=0
_module_commands_count=0
_module_commands_count_all=0
# shellcheck disable=SC2034,SC2154
_static_menu="${_tmp}/.static.menu"
# shellcheck disable=SC2154
_modules_count=$(find "${_modules}" -name '*.mod' | wc -l)
: >"${_static_menu}"
printf "\\n\\e[1;38m %-25.25s %-12.12s %s\\e[m\\n %-25.25s %-12.12s %s\\n\\n" \
"Module" \
"Profiles" \
"Description" \
"------" \
"--------" \
"-----------" >> "${_static_menu}"
# shellcheck disable=SC2154
for i in "${modules_full_list[@]}" ; do
_module_commands_count=0
# shellcheck disable=SC2034
_fname=$(echo "$i" | awk -v FS="(:|:)" '{print $1}')
# shellcheck disable=SC2034
_fpath=$(echo "$i" | awk -v FS="(:|:)" '{print $2}')
# shellcheck disable=SC1090
source "${_modules}/${_fpath}"
# shellcheck disable=SC2034
module_name="$_fname"
"${_fname}"
_module_commands_count=$((_module_commands_count + ${#_module_commands[*]}))
_module_commands_count_all=$((_module_commands_count_all + _module_commands_count))
printf " \\e[1;36m%-25.25s\\e[m \\e[1;33m%-12.12s\\e[m %s\\n" \
"$_fname" "$_module_commands_count" "$description" >> "${_static_menu}"
done
printf "\\n %s: \\e[1;39m%s\\e[m\\n %s: \\e[1;39m%s\\e[m\\n\\n" \
"All Modules" "$_modules_count" \
"All Profiles" "$_module_commands_count_all" >> "${_static_menu}"
cat "${_static_menu}"
: >"${_static_menu}"
return $_STATE
}