-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamples.ps1
More file actions
143 lines (126 loc) · 4.4 KB
/
samples.ps1
File metadata and controls
143 lines (126 loc) · 4.4 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
#!/usr/bin/env pwsh
<#
.SYNOPSIS
DevPossible.Ton Sample Programs Launcher
.DESCRIPTION
Interactive launcher for DevPossible.Ton sample programs across all languages
.NOTES
Copyright (c) 2024 DevPossible, LLC
#>
function Show-Menu {
Clear-Host
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " DevPossible.Ton Sample Programs Launcher " -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Select a language to run sample programs:" -ForegroundColor Yellow
Write-Host ""
Write-Host " 1. C# Samples (.NET 8.0)" -ForegroundColor Green
Write-Host " 2. JavaScript Samples (Node.js)" -ForegroundColor Green
Write-Host " 3. Python Samples (Python 3.x)" -ForegroundColor Green
Write-Host ""
Write-Host " 0. Exit" -ForegroundColor Red
Write-Host ""
}
function Run-CSharpSamples {
Write-Host ""
Write-Host "Launching C# Samples..." -ForegroundColor Cyan
Write-Host ""
$originalLocation = Get-Location
try {
Set-Location "src/CSharp/DevPossible.Ton.Samples"
# Check if dotnet is available
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
Write-Host "Error: .NET SDK not found. Please install .NET 8.0 or later." -ForegroundColor Red
Write-Host "Download from: https://dotnet.microsoft.com/download" -ForegroundColor Yellow
return
}
dotnet run
}
finally {
Set-Location $originalLocation
}
}
function Run-JavaScriptSamples {
Write-Host ""
Write-Host "Launching JavaScript Samples..." -ForegroundColor Cyan
Write-Host ""
$originalLocation = Get-Location
try {
Set-Location "src/JavaScript/devpossible-ton-samples"
# Check if node is available
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Host "Error: Node.js not found. Please install Node.js." -ForegroundColor Red
Write-Host "Download from: https://nodejs.org/" -ForegroundColor Yellow
return
}
node index.js
}
finally {
Set-Location $originalLocation
}
}
function Run-PythonSamples {
Write-Host ""
Write-Host "Launching Python Samples..." -ForegroundColor Cyan
Write-Host ""
$originalLocation = Get-Location
try {
Set-Location "src/Python/devpossible_ton_samples"
# Check if python is available
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Write-Host "Error: Python not found. Please install Python 3.x." -ForegroundColor Red
Write-Host "Download from: https://www.python.org/downloads/" -ForegroundColor Yellow
return
}
python index.py
}
finally {
Set-Location $originalLocation
}
}
# Main script loop
$continue = $true
while ($continue) {
Show-Menu
$choice = Read-Host "Enter your choice"
switch ($choice) {
"1" {
Run-CSharpSamples
if ($continue) {
Write-Host ""
Write-Host "Press any key to return to the main menu..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
}
"2" {
Run-JavaScriptSamples
if ($continue) {
Write-Host ""
Write-Host "Press any key to return to the main menu..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
}
"3" {
Run-PythonSamples
if ($continue) {
Write-Host ""
Write-Host "Press any key to return to the main menu..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
}
"0" {
Clear-Host
Write-Host ""
Write-Host "Thank you for using DevPossible.Ton!" -ForegroundColor Cyan
Write-Host "Visit https://tonspec.com for more information." -ForegroundColor Yellow
Write-Host ""
$continue = $false
}
default {
Write-Host ""
Write-Host "Invalid choice. Please try again." -ForegroundColor Red
Start-Sleep -Seconds 2
}
}
}