mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-18 16:13:24 +02:00
36 lines
559 B
Go
36 lines
559 B
Go
package cli
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
|
|
"definitive-opensource/data"
|
|
)
|
|
|
|
func selectPlatforms(scanner *bufio.Scanner) ([]string, error) {
|
|
platforms, err := data.LoadPlatforms()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
selected := []string{}
|
|
|
|
for {
|
|
fmt.Println("Select platforms (0 to finish):")
|
|
for i, p := range platforms {
|
|
fmt.Printf("%d) %s\n", i+1, p.Name)
|
|
}
|
|
|
|
var idx int
|
|
fmt.Scanln(&idx)
|
|
if idx == 0 {
|
|
break
|
|
}
|
|
if idx > 0 && idx <= len(platforms) {
|
|
selected = append(selected, platforms[idx-1].ID)
|
|
}
|
|
}
|
|
|
|
return selected, nil
|
|
}
|