forked from OpenEye-Dev/theiaDR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.sh
executable file
·40 lines (34 loc) · 922 Bytes
/
control.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
#! /bin/bash
# Load configs and commands
source ./project-config
source ./control-commands
current_dir=$(basename "$PWD")
# Program logic
if [[ $# -gt 0 ]]
then
echo "Looking for complete commands"
echo "If not recognized, print usage"
display_usage
else
clear
# Display commands and let user choose
while : ;
do
echo "Choose a command using its number:"
for ((i=1;i <= ${#AVAILABLE_COMMANDS[@]}; i++));
do
echo $i. ${AVAILABLE_COMMANDS[i-1]}
done
read choice
if [[ $choice =~ ^[0-9]+$ && ${choice} -gt 0 && ${choice} -lt ${#AVAILABLE_COMMANDS[@]}+1 ]]
then
CHOSEN_COMMAND=${AVAILABLE_COMMANDS[$choice-1]/.\//}
break
else
clear
echo -e "Unrecognized command. Type a number among the one shown below.\n"
fi
done
# Calling command function
cmd_$CHOSEN_COMMAND
fi