feat: support both comma and space separated selection
This commit is contained in:
parent
bb2b87f132
commit
3e8877fb80
|
|
@ -1,4 +1,4 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Skript ustanovki programm
|
# Skript ustanovki programm
|
||||||
# Zapusk: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/setup.ps1 | iex
|
# Zapusk: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/setup.ps1 | iex
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
@ -94,7 +94,7 @@ foreach ($prog in $programList) {
|
||||||
Write-Host "`n a - ALL programs" -ForegroundColor Green
|
Write-Host "`n a - ALL programs" -ForegroundColor Green
|
||||||
Write-Host " 0 - Cancel`n" -ForegroundColor Gray
|
Write-Host " 0 - Cancel`n" -ForegroundColor Gray
|
||||||
|
|
||||||
$choice = Read-Host "Select (numbers separated by space, or a)"
|
$choice = Read-Host "Select (1 2 3 or 1,2,3 or a)"
|
||||||
|
|
||||||
if ($choice -eq "0") {
|
if ($choice -eq "0") {
|
||||||
Write-Host "Canceled" -ForegroundColor Red
|
Write-Host "Canceled" -ForegroundColor Red
|
||||||
|
|
@ -105,7 +105,9 @@ $selectedPrograms = @()
|
||||||
if ($choice -eq "a") {
|
if ($choice -eq "a") {
|
||||||
$selectedPrograms = $allPrograms
|
$selectedPrograms = $allPrograms
|
||||||
} else {
|
} else {
|
||||||
foreach ($num in ($choice -split '\s+') | Where-Object { $_ -match '^\d+$' }) {
|
# Поддержка: "1, 2, 3" или "1 2 3" или "1,2,3"
|
||||||
|
$normalized = $choice -replace ',', ' '
|
||||||
|
foreach ($num in ($normalized -split '\s+') | Where-Object { $_ -match '^\d+$' }) {
|
||||||
if ($progMap[[int]$num]) {
|
if ($progMap[[int]$num]) {
|
||||||
$selectedPrograms += $progMap[[int]$num]
|
$selectedPrograms += $progMap[[int]$num]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue