-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument-tools
executable file
·77 lines (70 loc) · 2.1 KB
/
document-tools
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
#!/bin/bash
commands=(
"Compare Documents"
"Duplicate Line Remover"
"Find Word"
"Find Word Archive"
"Keyword Line Extractor"
"Replace Keyword"
"Quit"
)
selected=0
# Function to display the list and highlight the selected item
display_list() {
clear
echo -e "\033[1m Document Tools\033[0m\n --------------"
for i in "${!commands[@]}"; do
if [ $i -eq $selected ]; then
echo -e "\033[1m➤ ${commands[$i]}\033[0m\n"
else
echo -e " ${commands[$i]}\n"
fi
done
}
# Function to execute the selected command
execute_command() {
case ${commands[$selected]} in
"Compare Documents")
python3 Document-Tools/tools/compare-documents.py
read -p "Press Enter to return to the menu..."
;;
"Duplicate Line Remover")
python3 Document-Tools/tools/duplicate-line-remover.py
read -p "Press Enter to return to the menu..."
;;
"Find Word")
python3 Document-Tools/tools/find-word.py
read -p "Press Enter to return to the menu..."
;;
"Find Word Archive")
python3 Document-Tools/tools/find-word-archive.py
read -p "Press Enter to return to the menu..."
;;
"Keyword Line Extractor")
python3 Document-Tools/tools/keyword-line-extractor.py
read -p "Press Enter to return to the menu..."
;;
"Replace Keyword")
python3 Document-Tools/tools/replace-keyword.py
read -p "Press Enter to return to the menu..."
;;
"Quit")
echo -e "\n\033[1mExiting script\033[0m"
exit 0
;;
*)
echo -e "\nInvalid selection"
;;
esac
}
# Main loop
while true; do
display_list
read -sn 1 key
case $key in
"A") ((selected--)); [ $selected -lt 0 ] && selected=$(( ${#commands[@]} - 1 ));;
"B") ((selected++)); [ $selected -ge ${#commands[@]} ] && selected=0 ;;
"") execute_command ;;
*) ;;
esac
done