-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
module_software_template.sh
48 lines (38 loc) · 1.1 KB
/
module_software_template.sh
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
declare -A module_options
module_options+=(
["module_template,author"]="@Tearran"
["module_template,feature"]="module_template"
["module_template,example"]="install remove help"
["module_template,desc"]="Example module unattended interface."
["module_template,status"]="review"
)
function module_template() {
local title="test"
local condition=$(which "$title" 2>/dev/null)
# Convert the example string to an array
local commands
IFS=' ' read -r -a commands <<< "${module_options["module_template,example"]}"
case "$1" in
"${commands[0]}")
echo "Installing $title..."
# Installation logic here
;;
"${commands[1]}")
echo "Removing $title..."
# Removal logic here
;;
"${commands[2]}")
echo -e "\nUsage: ${module_options["module_template,feature"]} <command>"
echo -e "Commands: ${module_options["module_template,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tremove\t- Remove $title."
echo
;;
*)
${module_options["module_template,feature"]} ${commands[2]}
;;
esac
}
# uncomment to test the module
module_template "$1"