Started work on the add_server function.
This commit is contained in:
parent
412ef74e91
commit
194aa901bf
32
tojam
32
tojam
@ -28,7 +28,37 @@ declare -A command=(
|
|||||||
|
|
||||||
|
|
||||||
add_server() {
|
add_server() {
|
||||||
echo "Add server coming soon"
|
# Have to validate the form
|
||||||
|
local errorMessage
|
||||||
|
local valid="false"
|
||||||
|
while [[ "${valid}" != "true" ]]; do
|
||||||
|
valid="true"
|
||||||
|
serverInfo="$(dialog --backtitle "Tojam" --title "Add Server" \
|
||||||
|
--form "\nEnter Server Information:\n\nUse up and down to move between fields, enter to accept, or escape to cancel." 25 60 16 \
|
||||||
|
"Server Name:" 1 1 "" 1 25 25 50 \
|
||||||
|
"Server Address:" 2 1 "" 2 25 25 50 \
|
||||||
|
"Server Port:" 4 1 "2049" 4 25 6 6 --stdout)"
|
||||||
|
mapfile -t serverInfo < <(echo "${serverInfo//^$/}")
|
||||||
|
if [[ "${#serverInfo[0]}" -le 1 ]]; then
|
||||||
|
errorMessage+="Server name was missing.\n"
|
||||||
|
valid="false"
|
||||||
|
fi
|
||||||
|
if [[ "${#serverInfo[1]}" -le 1 ]]; then
|
||||||
|
errorMessage+="Server address was missing.\n"
|
||||||
|
valid="false"
|
||||||
|
fi
|
||||||
|
if ! [[ "${serverInfo[2]}" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
|
errorMessage+="Port must be numeric."
|
||||||
|
valid="false"
|
||||||
|
fi
|
||||||
|
if [[ "${valid}" == "false" ]]; then
|
||||||
|
dialog --backtitle "Tojam" \
|
||||||
|
--msgbox "${errorMessage}" -1 -1
|
||||||
|
errorMessage=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
servers[${serverInfo[0]}]="${serverInfo[1]}:${serverInfo[2]}"
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user