-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·406 lines (353 loc) · 11.3 KB
/
run.sh
File metadata and controls
executable file
·406 lines (353 loc) · 11.3 KB
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#!/bin/bash
# PromptResponse Launcher Script
#
# This script provides an easy way to run the PromptResponse application.
# By default, it opens the Field Types Demo to showcase all control types. Use options to override.
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_header() {
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE} $1${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_error() {
echo -e "${RED}✗ $1${NC}"
}
print_info() {
echo -e "${YELLOW}ℹ $1${NC}"
}
# Function to build the project
build_project() {
print_header "Building PromptResponse"
if dotnet build > /dev/null 2>&1; then
print_success "Build completed successfully"
return 0
else
print_error "Build failed"
echo "Run 'dotnet build' to see detailed error messages"
return 1
fi
}
# Function to run tests
run_tests() {
print_header "Running Tests"
dotnet test --verbosity quiet
}
# Function to launch GUI
launch_gui() {
print_header "Launching PromptResponse Desktop Application"
if [ -n "$2" ]; then
print_info "Opening file: $2"
fi
print_info "Starting GUI application with debug logging enabled..."
print_info "All debug output will be shown below:"
echo ""
echo "${BLUE}─────────────────── Application Debug Log ───────────────────${NC}"
echo ""
# Run with full output visible
# Arguments: $1 = mode flag (--open or --edit), $2 = file path
if [ -n "$1" ] && [ -n "$2" ]; then
dotnet run --project src/PromptResponse.Desktop -- "$1" "$2"
else
dotnet run --project src/PromptResponse.Desktop
fi
local exit_code=$?
echo ""
echo "${BLUE}──────────────────────────────────────────────────────────────${NC}"
if [ $exit_code -eq 0 ]; then
print_success "Application exited normally"
else
print_error "Application exited with code: $exit_code"
fi
return $exit_code
}
# Function to open a file for filling
open_file() {
local file="$1"
if [ ! -f "$file" ]; then
print_error "File not found: $file"
return 1
fi
launch_gui "--open" "$file"
}
# Function to open a file for editing
edit_file() {
local file="$1"
if [ ! -f "$file" ]; then
print_error "File not found: $file"
return 1
fi
launch_gui "--edit" "$file"
}
# Function to show CLI help
show_cli_help() {
print_header "PromptResponse CLI Help"
dotnet run --project src/PromptResponse.Cli -- help
}
# Function to validate example files
demo_validate() {
print_header "Demo: Validating APR Files"
if [ ! -d "examples" ]; then
print_error "Examples directory not found"
return 1
fi
for file in examples/*.apr; do
if [ -f "$file" ]; then
echo ""
print_info "Validating: $(basename "$file")"
dotnet run --project src/PromptResponse.Cli -- validate "$file"
fi
done
}
# Function to show info about example files
demo_info() {
print_header "Demo: APR File Information"
if [ ! -d "examples" ]; then
print_error "Examples directory not found"
return 1
fi
for file in examples/*.apr; do
if [ -f "$file" ]; then
echo ""
dotnet run --project src/PromptResponse.Cli -- info "$file"
echo ""
read -p "Press Enter to continue to next file..."
fi
done
}
# Function to create a new template demo
demo_new_template() {
print_header "Demo: Creating New Template"
local demo_file="demo-template.apr"
if [ -f "$demo_file" ]; then
print_info "Removing existing demo file..."
rm "$demo_file"
fi
print_info "Creating new template interactively..."
echo ""
dotnet run --project src/PromptResponse.Cli -- new "$demo_file"
echo ""
if [ -f "$demo_file" ]; then
print_success "Template created: $demo_file"
echo ""
print_info "Validating the new template..."
dotnet run --project src/PromptResponse.Cli -- validate "$demo_file"
echo ""
print_info "Showing template info..."
dotnet run --project src/PromptResponse.Cli -- info "$demo_file"
fi
}
# Function to run all CLI demos
demo_all() {
print_header "PromptResponse CLI Demo Suite"
print_info "This will demonstrate all CLI features"
echo ""
read -p "Press Enter to start..."
# 1. Show help
echo ""
show_cli_help
echo ""
read -p "Press Enter to continue..."
# 2. Validate examples
echo ""
demo_validate
echo ""
read -p "Press Enter to continue..."
# 3. Show info
echo ""
demo_info
# 4. Create new template
echo ""
print_info "Would you like to create a demo template? (y/n)"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
demo_new_template
fi
echo ""
print_header "Demo Complete"
print_success "All CLI demos completed successfully!"
}
# Show usage information
show_usage() {
cat << EOF
${BLUE}PromptResponse Launcher${NC}
${GREEN}Usage:${NC}
./run.sh [OPTION] [FILE]
${GREEN}Options:${NC}
${YELLOW}(none)${NC} Open Field Types Demo to showcase all controls (default)
${YELLOW}--no-file${NC} Launch GUI without opening any file
${YELLOW}--gui, -g${NC} Launch GUI without opening any file (same as --no-file)
${YELLOW}--open <file>${NC} Open an APR file for filling out
${YELLOW}--edit <file>${NC} Open an APR template for editing
${YELLOW}<file>${NC} Open an APR file for filling out (same as --open)
${YELLOW}--help, -h${NC} Show CLI help information
${YELLOW}--demo${NC} Run interactive CLI demo suite
${YELLOW}--validate${NC} Validate all example APR files
${YELLOW}--info${NC} Show information about example files
${YELLOW}--new${NC} Create a new template (interactive)
${YELLOW}--test${NC} Run all tests
${YELLOW}--build${NC} Build the project only
${YELLOW}--version${NC} Show version information
${YELLOW}--icon${NC} View the application icon in browser
${YELLOW}--usage${NC} Show this usage information
${GREEN}Examples:${NC}
./run.sh # Open Field Types Demo (default - shows all controls)
./run.sh --no-file # Launch GUI without opening any file
./run.sh --open examples/simple-contact-form.aprt # Open contact form for filling
./run.sh --edit examples/sf-86-full-template.aprt # Edit SF-86 template
./run.sh examples/myform.aprf # Open filled form
./run.sh --demo # Run full CLI demo
./run.sh --validate # Validate example files
./run.sh --help # Show CLI help
${GREEN}Project Information:${NC}
PromptResponse - A cross-platform form creation and filling application
Technology: .NET 8.0, C# 12, AvaloniaUI 11
License: GPL-3.0
EOF
}
# Show version
show_version() {
print_header "PromptResponse Version Information"
dotnet run --project src/PromptResponse.Cli -- version
echo ""
dotnet --version
}
# Main script logic
main() {
# Check if we're in the right directory
if [ ! -f "PromptResponse.sln" ]; then
print_error "Error: Must be run from the PromptResponse project root directory"
exit 1
fi
# Default file to open when no arguments provided
local default_file="examples/field-types-demo.aprt"
# If no arguments, build and open default file in form mode
if [ $# -eq 0 ]; then
build_project || exit 1
echo ""
if [ -f "$default_file" ]; then
open_file "$default_file"
else
print_error "Default file not found: $default_file"
launch_gui
fi
exit 0
fi
# Parse command line arguments
case "$1" in
--gui|-g)
build_project || exit 1
echo ""
launch_gui
;;
--no-file)
build_project || exit 1
echo ""
launch_gui
;;
--open)
if [ -z "$2" ]; then
print_error "Error: --open requires a file path"
echo ""
show_usage
exit 1
fi
build_project || exit 1
echo ""
open_file "$2"
;;
--edit)
if [ -z "$2" ]; then
print_error "Error: --edit requires a file path"
echo ""
show_usage
exit 1
fi
build_project || exit 1
echo ""
edit_file "$2"
;;
--help|-h)
build_project || exit 1
echo ""
show_cli_help
;;
--demo)
build_project || exit 1
echo ""
demo_all
;;
--validate)
build_project || exit 1
echo ""
demo_validate
;;
--info)
build_project || exit 1
echo ""
demo_info
;;
--new)
build_project || exit 1
echo ""
demo_new_template
;;
--test)
build_project || exit 1
echo ""
run_tests
;;
--build)
dotnet build
;;
--version|-v)
build_project || exit 1
echo ""
show_version
;;
--icon)
print_header "Application Icon Preview"
if command -v xdg-open &> /dev/null; then
xdg-open src/PromptResponse.Desktop/Assets/icon-preview.html
elif command -v open &> /dev/null; then
open src/PromptResponse.Desktop/Assets/icon-preview.html
else
print_info "Open this file in your browser:"
echo " file://$(pwd)/src/PromptResponse.Desktop/Assets/icon-preview.html"
fi
;;
--usage)
show_usage
;;
-*)
print_error "Unknown option: $1"
echo ""
show_usage
exit 1
;;
*)
# If it's a file path (not starting with --), treat as --open
if [ -f "$1" ]; then
build_project || exit 1
echo ""
open_file "$1"
else
print_error "File not found: $1"
echo ""
show_usage
exit 1
fi
;;
esac
}
# Run main function
main "$@"