-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev-test-protocol.ps1
More file actions
72 lines (67 loc) · 2.38 KB
/
Copy pathdev-test-protocol.ps1
File metadata and controls
72 lines (67 loc) · 2.38 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
# Quick test runner for cpally:// deep link scenarios.
# Usage:
# .\dev-test-protocol.ps1 - interactive menu
# .\dev-test-protocol.ps1 cold 1A - cold-launch problem 1A
# .\dev-test-protocol.ps1 hot 2208A - hot-handoff problem 2208A
# .\dev-test-protocol.ps1 log - tail diagnostics.log
param(
[string]$Mode = "",
[string]$Code = "1A"
)
$logPath = "$env:APPDATA\CompetitiveProgrammingAlly\diagnostics.log"
function Show-Log {
if (Test-Path $logPath) {
Write-Host "`n--- Last 30 lines of diagnostics.log ---" -ForegroundColor Cyan
Get-Content $logPath -Tail 30
} else {
Write-Host "Log not found: $logPath" -ForegroundColor Yellow
Write-Host "(App hasn't written it yet — check if the app started at all.)"
}
}
function Launch-Url([string]$url) {
Write-Host "Launching: $url" -ForegroundColor Yellow
Start-Process $url
Start-Sleep -Seconds 3
Show-Log
}
switch ($Mode.ToLower()) {
"cold" {
Write-Host "Cold-launch test. Close the app now if it is running, then press Enter." -ForegroundColor Green
Read-Host
Launch-Url "cpally://problem/$Code"
}
"hot" {
Write-Host "Hot-handoff test. The app must already be running." -ForegroundColor Green
Write-Host "Press Enter to send the URL."
Read-Host
Launch-Url "cpally://problem/$Code"
}
"log" {
Show-Log
}
default {
Write-Host "cpally:// dev test tool" -ForegroundColor Cyan
Write-Host ""
Write-Host "1) Cold launch - app is NOT running; link should open it and load problem"
Write-Host "2) Hot handoff - app IS running; link should load problem in running window"
Write-Host "3) Show log"
Write-Host "4) Exit"
Write-Host ""
$choice = Read-Host "Choice"
switch ($choice) {
"1" {
$code = Read-Host "Problem code (e.g. 1A)"
Write-Host "Close the app if it is open, then press Enter."
Read-Host
Launch-Url "cpally://problem/$code"
}
"2" {
$code = Read-Host "Problem code (e.g. 2208A)"
Write-Host "Make sure the app is already running, then press Enter."
Read-Host
Launch-Url "cpally://problem/$code"
}
"3" { Show-Log }
}
}
}