feat(toolkit): number menu entries automatically
The menu is now a list of entries in display order; the numbers 1-24 are assigned at startup instead of being hand-picked per item, so adding or moving an entry never needs renumbering. Dispatch keeps stable internal ids. README reference to 'delete tenant auth and app registration' is now item 24.
This commit is contained in:
+13
-2
@@ -326,7 +326,9 @@ $commonParams = @{
|
||||
SettingsFile = $SettingsFile
|
||||
}
|
||||
|
||||
$menuItems = @(
|
||||
# Menu entries in display order. Id is the internal dispatch id used below; the number shown to the user
|
||||
# is assigned automatically, so entries can be added or moved without renumbering anything.
|
||||
$menuDefs = @(
|
||||
# Export / Import
|
||||
"1. Export policies"
|
||||
"2. Import policies"
|
||||
@@ -358,6 +360,14 @@ $menuItems = @(
|
||||
"15. Delete tenant auth and app registration"
|
||||
"0. Exit"
|
||||
)
|
||||
$menuIdByNumber = @{}
|
||||
$menuItems = @()
|
||||
for($i = 0; $i -lt $menuDefs.Count; $i++)
|
||||
{
|
||||
$menuIdByNumber[$i + 1] = $menuDefs[$i].Id
|
||||
$menuItems += ("{0}." -f ($i + 1)).PadRight(4) + $menuDefs[$i].Label
|
||||
}
|
||||
$menuItems += "0.".PadRight(4) + "Exit"
|
||||
|
||||
while($true)
|
||||
{
|
||||
@@ -386,7 +396,8 @@ while($true)
|
||||
exit 0
|
||||
}
|
||||
|
||||
$choiceNumber = [int]($selection -replace "^(\d+)\..*$", '$1')
|
||||
$choiceNumber = $menuIdByNumber[[int]($selection -replace "^(\d+)\..*$", '$1')]
|
||||
if($null -eq $choiceNumber) { continue }
|
||||
|
||||
$script = $null
|
||||
switch($choiceNumber)
|
||||
|
||||
Reference in New Issue
Block a user