fix: deploy menu numbers only undeployed nodes
This commit is contained in:
parent
c49ee64b0b
commit
216b24b9ac
1 changed files with 6 additions and 8 deletions
|
|
@ -221,20 +221,18 @@ func deployMenu() {
|
|||
fmt.Println("\n─── Deploy Node ───")
|
||||
available := []int{}
|
||||
for i, nc := range nodes {
|
||||
marker := " "
|
||||
if deployed[nc.Name] {
|
||||
marker = "✓ "
|
||||
}
|
||||
fmt.Printf(" %s[%d] %s (port %s)\n", marker, i+1, nc.Name, nc.Port)
|
||||
if !deployed[nc.Name] {
|
||||
fmt.Printf(" ✓ %s (port %s) [deployed]\n", nc.Name, nc.Port)
|
||||
} else {
|
||||
available = append(available, i)
|
||||
fmt.Printf(" [%d] %s (port %s)\n", len(available), nc.Name, nc.Port)
|
||||
}
|
||||
}
|
||||
if len(available) == 0 {
|
||||
fmt.Println("All nodes deployed.")
|
||||
return
|
||||
}
|
||||
fmt.Print("\nSelect node number (or Enter for all undeployed): ")
|
||||
fmt.Print("\nSelect node number (or Enter for all): ")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
choice, _ := reader.ReadString('\n')
|
||||
choice = strings.TrimSpace(choice)
|
||||
|
|
@ -244,11 +242,11 @@ func deployMenu() {
|
|||
for _, i := range available { selected = append(selected, nodes[i]) }
|
||||
} else {
|
||||
idx, err := strconv.Atoi(choice)
|
||||
if err != nil || idx < 1 || idx > len(nodes) {
|
||||
if err != nil || idx < 1 || idx > len(available) {
|
||||
fmt.Println("Invalid choice")
|
||||
return
|
||||
}
|
||||
selected = append(selected, nodes[idx-1])
|
||||
selected = append(selected, nodes[available[idx-1]])
|
||||
}
|
||||
|
||||
for _, nc := range selected {
|
||||
|
|
|
|||
Loading…
Reference in a new issue