-
Notifications
You must be signed in to change notification settings - Fork 223
/
Copy pathmodule_show
128 lines (87 loc) · 3.01 KB
/
module_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env bash
# shellcheck shell=bash
# ``````````````````````````````````````````````````````````````````````````````
# Function name: module_show()
#
# Description:
# Show help in cli.
#
# Usage:
# module_show
#
# Examples:
# module_show
#
function module_show() {
# shellcheck disable=SC2034
local _FUNCTION_ID="module_show"
local _STATE=0
local _marg="$1"
_count=0
_cr="-35.35"
# shellcheck disable=SC2034,SC2154
_static_menu="${_tmp}/.static.menu"
: >"${_static_menu}"
if [[ -z "$_marg" ]] ; then
printf "\\n \\e[1;38m%-4.4s %${_cr}s %s\\e[m\\n %-4.4s %${_cr}s %s\\n\\n" \
"ID" \
"Alias" \
"Nmap Parameters" \
"--" \
"-----" \
"---------------" >> "${_static_menu}"
fi
# shellcheck disable=SC2034,SC2154
for _svar in "${_module_commands[@]}" ; do
# shellcheck disable=SC2034
_key_desc=$(echo "$_svar" | awk -v FS="(;|;)" '{print $1}')
# shellcheck disable=SC2034
_key_comm=$(echo "$_svar" | awk -v FS="(;|;)" '{print $2}')
# shellcheck disable=SC2034
_key_alias=$(echo "$_svar" | awk -v FS="(;|;)" '{print $3}')
# shellcheck disable=SC2034
_key_cmd=$(echo "$_svar" | awk -v FS="(;|;)" '{print $4}')
# shellcheck disable=SC2034
_key_arg=$(echo "$_svar" | awk -v FS="(;|;)" '{print $5}')
# shellcheck disable=SC2034
IFS="," read -r -a _script_args <<< "$(sed 's/,\s+/???/g' <<< "$_key_arg")"
if [[ "$_key_alias" == "$_marg" ]] ; then
printf "\\n \\e[1;38m%-4.4s %${_cr}s %s\\e[m\\n %-4.4s %${_cr}s %s\\n\\n" \
"ID" \
"Alias" \
"Nmap Parameters" \
"--" \
"-----" \
"---------------" >> "${_static_menu}"
printf " \\e[1;32m%-4.4s\\e[m \\e[1;34m%${_cr}s\\e[m %s\\n" \
"$_count" \
"$_key_alias" \
"$_key_cmd" >> "${_static_menu}"
if [[ ! "${#_script_args[@]}" -eq 0 ]] ; then
printf "\\n \\e[1;38m%s\\e[m:\\n\\n" "Script arguments" >> "${_static_menu}"
for i in "${_script_args[@]}" ; do
# shellcheck disable=SC2001
_tmp_script_args=$(echo "${i}" | sed 's/^ *//g' | sed 's/???/\\n/g')
if [[ "${_tmp_script_args}" == *"="* ]] ; then
_a_arg=$(echo "${_tmp_script_args}" | tr -d '"' | cut -d "=" -f1)
_b_arg=$(echo "${_tmp_script_args}" | tr -d '"' | cut -d "=" -f2)
printf " %s = '\\e[1;33m%s\\e[m'\\n" "${_a_arg}" "${_b_arg}" >> "${_static_menu}"
else
_a_arg=$(echo "${_tmp_script_args}" | tr -d '"')
printf " %s = ''\\n" "${_a_arg}" >> "${_static_menu}"
fi
done
fi
elif [[ -z "$_marg" ]] ; then
printf " \\e[1;32m%-4.4s\\e[m \\e[1;34m%${_cr}s\\e[m %s\\n" \
"$_count" \
"$_key_alias" \
"$_key_cmd" >> "${_static_menu}"
fi
_count=$((_count + 1))
done
cat "${_static_menu}"
echo
: >"${_static_menu}"
return $_STATE
}