Private/Show-RocketStandMenu.ps1
function Show-RocketStandMenu { $selectedValues = @{} $options = @("Rocket GUI", "Rocket Forms") foreach ($option in $options) { $selectedValues[$option] = $false } $actualIndex = 0 # rocket ASCII $rocket = @" ___ || | | / \ | | |--o-|===|-| |----| | | / \ | | | P | | | | S |=| | | 1 | | | |_______| |_| |@| |@| | | ___________|_|_ "@ function Draw-Menu { Clear-Host Write-Host "[Rocket-CLI] Select the modules you want to include in your project`n" -ForegroundColor Green $rocketLines = $rocket -split "`n" $menuLines = @() for ($i = 0; $i -lt $options.Count; $i++) { $checked = if ($selectedValues[$options[$i]]) { "[x]" } else { "[ ]" } if ($i -eq $actualIndex) { $menuLines += "=> $checked $($options[$i])" } else { $menuLines += " $checked $($options[$i])" } } $maxLines = [math]::Max($rocketLines.Count, $menuLines.Count) for ($lineIndex = 0; $lineIndex -lt $maxLines; $lineIndex++) { $rocketLine = if ($lineIndex -lt $rocketLines.Count) { $rocketLines[$lineIndex] } else { " " * $rocketLines[0].Length } $menuLine = if ($lineIndex -lt $menuLines.Count) { $menuLines[$lineIndex] } else { "" } Write-Host "$rocketLine $menuLine" } } $exit = $false do { Draw-Menu $key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").VirtualKeyCode switch ($key) { 38 { $actualIndex = if ($actualIndex -gt 0) { $actualIndex - 1 } else { $options.Count - 1 } } 40 { $actualIndex = if ($actualIndex -lt ($options.Count - 1)) { $actualIndex + 1 } else { 0 } } 32 { $selectedValues[$options[$actualIndex]] = -not $selectedValues[$options[$actualIndex]] } 13 { $exit = $true } } } while (-not $exit) return $selectedValues.GetEnumerator() | Where-Object { $_.Value } | ForEach-Object { $_.Key } } |