generated from trustoverip/specification-template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.sh
239 lines (219 loc) · 6.18 KB
/
main.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# Function to handle the user's choice
function handle_choice() {
if [[ "$choice" == "0" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Publish (= Add terms, create pdf, look up xrefs and create spec)"
echo " ************************************"
echo " "
echo " "
show_progress
do_publish
elif [[ "$choice" == "1" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Render specification"
echo " ************************************"
echo " "
echo " "
show_progress
do_render
elif [[ "$choice" == "2" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Export to PDF"
echo " ************************************"
echo " "
echo " "
show_progress
do_topdf
elif [[ "$choice" == "3" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Look up xrefs"
echo " ************************************"
echo " "
echo " "
show_progress
do_xrefs
elif [[ "$choice" == "4" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Remove xref"
echo " ************************************"
echo " "
echo " "
show_progress
do_removexref
elif [[ "$choice" == "5" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Validate config file"
echo " ************************************"
echo " "
echo " "
show_progress
do_validatespec
elif [[ "$choice" == "6" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Add new terms"
echo " ************************************"
echo " "
echo " "
show_progress
do_addterms
elif [[ "$choice" == "7" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Open documentation website"
echo " ************************************"
echo " "
echo " "
show_progress
do_help
elif [[ "$choice" == "8" ]]; then
echo " "
echo " "
echo " ************************************"
echo " Freeze specification"
echo " ************************************"
echo " "
echo " "
show_progress
do_freeze
# # Example of confirmation prompt
# elif [[ "$choice" == "4" ]]; then
# read -n 1 -r -p " Are you sure? (y/N) " confirm
# echo # Empty line below the prompt
# if [[ "$confirm" == [yY] ]]; then
# echo " "
# echo " "
# echo " ************************************"
# echo " The script will now …."
# echo " ************************************"
# echo " "
# echo " "
# show_progress
# do_something
# else
# echo "Cancelled."
# fi
else
clear
echo " "
echo " "
echo " ************************************"
echo " Goodbye! You chose to exit."
echo " ************************************"
echo " "
echo " "
fi
echo " "
echo " "
echo " "
echo " SPEC-UP-T: Type 'npm run menu' to return to the main menu."
echo " "
}
# Function to display the introduction text
function display_intro() {
clear
echo " "
echo " ,---. . . --.--"
echo " \`---.,---.,---.,---. | |,---. | "
echo " || ||---'| ---| || |--- | "
echo " \`---'|---'\`---'\`---' \`---'|---' \` "
echo " | | "
echo " "
echo " "
echo " Please choose one of the following options:"
echo " "
echo " [0] Publish ¹"
echo " "
echo " [1] Render specification"
echo " [2] Export to PDF"
echo " [3] Look up xrefs"
echo " [4] Remove xref"
echo " [5] Validate config file"
echo " [6] Add new terms"
echo " [7] Open documentation website"
echo " [8] Freeze specification"
echo " [Q] Quit"
echo " "
echo " "
echo " ¹ Publish = [6]+[2]+[3]+[1]"
}
# Function to prompt the user for input
function prompt_input() {
read -n 1 -r -p " Enter your choice (0/1/2/3/4/5/6/7/8/Q)? " choice
echo # Empty line below the prompt
echo # Empty line below the prompt
}
function do_render() {
clear
npm run render
}
function do_topdf() {
clear
npm run topdf
}
function do_xrefs() {
clear
npm run xrefs
}
function do_removexref() {
clear
npm run removexref
}
function do_validatespec() {
clear
npm run validatespec
}
function do_addterms() {
clear
npm run addterms
}
function do_freeze() {
clear
npm run freeze
}
function do_publish() {
clear
npm run publish
}
function do_help() {
clear
echo "\n\n\n You will be redirected to the documentation website\n\n (https://blockchainbird.github.io/spec-up-t-website/)."
sleep 2
if [[ "$OSTYPE" == "darwin"* ]]; then
open "https://blockchainbird.github.io/spec-up-t-website/docs/cheat-sheet/#start-command-line-menu"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
xdg-open "https://blockchainbird.github.io/spec-up-t-website/docs/cheat-sheet/#start-command-line-menu"
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
start "https://blockchainbird.github.io/spec-up-t-website/docs/cheat-sheet/#start-command-line-menu"
else
echo "Unsupported OS."
fi
}
# Function to show the progress of the scraping process
function show_progress() {
for i in {1..3}
do
printf "."
sleep 0.2
done
}
# Main script starts here
display_intro
prompt_input
handle_choice
# End of script