-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRazzleProfile.ps1
96 lines (86 loc) · 2.67 KB
/
RazzleProfile.ps1
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
Add-Type -AssemblyName System.Windows.Forms
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
function GetRazzleParameters {
Write-Output "There is a dialog windows, select your os folder..."
$folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$folderBrowser.Description = "Select os.2020 folder"
$folderBrowser.RootFolder = "MyComputer"
$folderBrowser.ShowNewFolderButton = $true
$result = $folderBrowser.ShowDialog()
if ($result -eq 'OK') {
$selectedFolder = $folderBrowser.SelectedPath
if ((Get-Item $selectedFolder).Name -ne "src") {
$selectedFolder = Join-Path -Path $selectedFolder -ChildPath "src"
}
Write-Output "Razzle path selected: $selectedFolder"
$archDefault = "amd64fre"
$arch = Read-Host -Prompt "Input Arch (Enter for default: $archDefault)"
if ($arch -eq "") {
$arch = $archDefault
}
$flagDefault = "dev_build"
$flag = Read-Host -Prompt "Input Flag (Enter for default: $flagDefault)"
if ($flag -eq "") {
$flag = $flagDefault
}
}
else {
exit 1
}
return @{
Path = $selectedFolder
Arch = $arch
Flag = $flag
}
}
function DirectRazzle {
$pars = GetRazzleParameters
raz $pars.Path $pars.Arch -Flags $pars.Flag
}
function RazzleTerminalProfile {
$options = @("Add Profile", "Remove Profile")
Write-Host "Choose an option:"
for ($i=0; $i -lt $options.Count; $i++) {
Write-Host " $($i+1). $($options[$i])"
}
$choice = Read-Host "Enter your operation"
if ($choice -eq "1") {
$pars = GetRazzleParameters
New-RazzleTerminalProfile `
-SrcDir $pars.Path `
-Arch $pars.Arch `
-Flags $pars.Flag
}
elseif ($choice -eq "2") {
Remove-RazzleTerminalProfile
}
}
function MainEntry {
$options = @("Direct Raz", "Razzle Terminal Profile")
Write-Host "Choose an option:"
for ($i=0; $i -lt $options.Count; $i++) {
Write-Host " $($i+1). $($options[$i])"
}
$choice = Read-Host "Enter your operation (default: Direct Raz)"
if ([string]::IsNullOrEmpty($choice)) {
DirectRazzle
}
if ($choice -eq "1") {
DirectRazzle
}
elseif ($choice -eq "2") {
RazzleTerminalProfile
}
}
try {
MainEntry
}
catch {
Write-Host "Exception:" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
Write-Host $_.Exception.StackTrace -ForegroundColor Red
exit 1
}
# Delete Self
$myPsPath = $MyInvocation.MyCommand.Path
Start-Process powershell -ArgumentList "Remove-Item `"$myPsPath`" -Force"