add colors to output

This commit is contained in:
Jonny_Bro (Nikita) 2024-12-02 19:20:23 +05:00
parent 177fa833a5
commit 37a97a7959

View file

@ -13,7 +13,7 @@ function Get-RegistryValue {
}
}
Write-Host "Searching for Steam installation..."
Write-Host "Searching for Steam installation..." -ForegroundColor White
# Get Steam installation path from registry
$steam_dir = Get-RegistryValue "HKLM:\SOFTWARE\Valve\Steam" "InstallPath"
@ -24,7 +24,7 @@ if (-not $steam_dir) {
# Fallback to searching for Steam.exe on all drives
if (-not $steam_dir) {
Write-Host "No registry key found. Searching for Steam executable on all drives..."
Write-Host "No registry key found. Searching for Steam executable on all drives..." -ForegroundColor Yellow
# Get all filesystem drives
$drives = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -match '^[A-Z]$' }
@ -42,12 +42,12 @@ if (-not $steam_dir) {
}
if (-not $steam_dir) {
Write-Host "Steam installation path not found"
Write-Host "Steam installation path not found" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit
}
Write-Host "Steam installation path: $steam_dir"
Write-Host "Steam installation path: $steam_dir" -ForegroundColor Cyan
# Initialize Garry's Mod directory as null
$gmod_dir = $null
@ -84,19 +84,19 @@ if (-not $gmod_dir) {
}
if (-not $gmod_dir) {
Write-Host "GMod installation path not found"
Write-Host "GMod installation path not found" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit
}
Write-Host "GMod installation path: $gmod_dir"
Write-Host "GMod installation path: $gmod_dir" -ForegroundColor Cyan
# Confirm Garry's Mod installation path
$GMODPath = Join-Path $gmod_dir "garrysmod"
$_text = "Do you want to install in this path? It will completely wipe the previous Beatrun install if you had one!`n$GMODPath (y/n)"
$GMODConfirmation = Read-Host $_text
Write-Host "Do you want to install in this path? It will completely wipe the previous Beatrun install if you had one!" -ForegroundColor Yellow
$GMODConfirmation = Read-Host "(y/n)"
if ($GMODConfirmation -eq "y") {
if ($GMODConfirmation -eq "y" -or $GMODConfirmation -eq "Y") {
# Define paths
$TempPath = Join-Path $GMODPath "temp"
$ZIPPath = Join-Path $TempPath "beatrun.zip"
@ -111,22 +111,22 @@ if ($GMODConfirmation -eq "y") {
}
# Download Beatrun zip
Write-Host "Downloading the Beatrun archive..."
Write-Host "Downloading the Beatrun archive..." -ForegroundColor White
try {
(New-Object Net.WebClient).DownloadFile("https://github.com/JonnyBro/beatrun/archive/refs/heads/main.zip", $ZIPPath)
Write-Host "Download successful!"
Write-Host "Download successful!" -ForegroundColor Green
} catch {
Write-Host "Error: Unable to download Beatrun. Please check your internet connection or URL."
Write-Host "Error: Unable to download Beatrun. Please check your internet connection or URL." -ForegroundColor Red
exit
}
# Unzip the archive
Write-Host "Unpacking the archive..."
Write-Host "Unpacking the archive..." -ForegroundColor White
try {
Expand-Archive -Path $ZIPPath -DestinationPath $TempPath -Force
Write-Host "Unpacking successful!"
Write-Host "Unpacking successful!" -ForegroundColor Green
} catch {
Write-Host "Error: Failed to unpack the Beatrun archive."
Write-Host "Error: Failed to unpack the Beatrun archive." -ForegroundColor Red
exit
}
@ -134,7 +134,7 @@ if ($GMODConfirmation -eq "y") {
if (Test-Path $FolderMainPath) {
Rename-Item -Path $FolderMainPath -NewName $FolderPath
} else {
Write-Host "Error: Unpacked folder not found."
Write-Host "Error: Unpacked folder not found." -ForegroundColor Red
exit
}
@ -143,15 +143,15 @@ if ($GMODConfirmation -eq "y") {
# Confirm the addon directory exists
if (Test-Path $NewAddonPath) {
Write-Host "Previous Beatrun installation found. Removing old installation..."
Write-Host "Previous Beatrun installation found. Removing old installation..." -ForegroundColor White
Remove-Item -Path $NewAddonPath -Recurse -Force
}
# Move the new Beatrun addon
Write-Host "Installing Beatrun..."
Write-Host "Installing Beatrun..." -ForegroundColor White
Move-Item -Path $AddonPath -Destination $NewAddonPath -Force
# Clean up temporary files
Remove-Item -Path $TempPath -Recurse -Force
Write-Host "Beatrun has been installed successfully!"
Write-Host "Beatrun has been installed successfully!" -ForegroundColor Green
}