-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.ps1
38 lines (34 loc) · 1.18 KB
/
Main.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
Set-Location $PSScriptRoot
[console]::WindowHeight = [Console]::WindowHeight - 5
# List components and show menu for user selection of which module to start
$components = @()
Get-ChildItem -Path ".\components" -Directory | ForEach-Object { $components += $_.BaseName }
# Run component directly if there is just a single one.
if ($components.Count -eq 1) {
$component = $components[0]
. ".\components\$component\$component.ps1"
exit
}
# Show menu and wait for user input, loops until valid input is provided
# Each component is enumerates with a number and the user can select the number to run the component
while ($true) {
do {
Clear-Host
Write-Host "Select a component to run:"
$num = 1
foreach ($component in $components) {
Write-Host " ($num) $component"
$num++
}
Write-Host ""
Write-Host "(x) Exit"
Write-Host ""
$mode = Read-Host "Please select an option"
if ($mode -eq 'x') {
exit
}
} while ($mode -notin 1..$components.Count)
# Run the selected component
$component = $components[$mode - 1]
. ".\components\$component\$component.ps1"
}