From da293ae85d011915be42f48721da5c3f92ea8d1e Mon Sep 17 00:00:00 2001 From: oqyude Date: Sat, 11 Oct 2025 15:06:06 +0300 Subject: [PATCH] prettier --- run.ps1 | 17 ++--------------- src/init.ps1 | 2 -- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 1587146..7f96a90 100644 --- a/run.ps1 +++ b/run.ps1 @@ -1,29 +1,20 @@ -# Define variables for administrator restart $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") $restartArgs = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -# Initalize environment -$initFile = Join-Path $PSScriptRoot ".\src\init.ps1" -. $initFile - -# Check for administrator privileges and restart if needed +. (Join-Path $PSScriptRoot "./src/init.ps1") if (-not $isAdmin) { Write-Host "The script requires administrator privileges. Restarting..." - - # Restart the script with admin rights Start-Process -FilePath "powershell.exe" -ArgumentList $restartArgs -Verb RunAs exit } Write-Host "Administrator privileges confirmed." -# Interactive module selection Clear-Host Write-Host "Select a module:" $moduleNames = $modules.Keys | Sort-Object for ($i = 0; $i -lt $moduleNames.Count; $i++) { Write-Host "[$($i+1)] $($moduleNames[$i])" } - do { $moduleSelection = Read-Host "Enter the number of your choice" $validModule = ($moduleSelection -as [int]) -and ($moduleSelection -ge 1) -and ($moduleSelection -le $moduleNames.Count) @@ -33,10 +24,8 @@ do { Clear-Host $selectedModule = $moduleNames[$moduleSelection - 1] $actions = $modules[$selectedModule] - Write-Host "Selected module: $selectedModule" -# Determine action: from argument or interactive menu if ($args.Count -ge 1) { $action = $args[0] } else { @@ -44,7 +33,6 @@ if ($args.Count -ge 1) { for ($i = 0; $i -lt $actions.Count; $i++) { Write-Host "[$($i+1)] $($actions[$i])" } - do { $selection = Read-Host "Enter the number of your choice" $valid = ($selection -as [int]) -and ($selection -ge 1) -and ($selection -le $actions.Count) @@ -57,5 +45,4 @@ if ($args.Count -ge 1) { Clear-Host Write-Host "Selected action: $action" -# Call the selected module with the chosen action -. (Get-Variable $selectedModule).Value $action \ No newline at end of file +& (Get-Variable $selectedModule).Value $action \ No newline at end of file diff --git a/src/init.ps1 b/src/init.ps1 index 229547c..940540d 100644 --- a/src/init.ps1 +++ b/src/init.ps1 @@ -1,8 +1,6 @@ -# Init Set-Location -Path $PSScriptRoot $root = Join-Path $PSScriptRoot ".." - $varsFile = Join-Path $root "src\vars.ps1" if (Test-Path $varsFile) { . $varsFile