mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-19 08:54:18 +02:00
Populated CLI with initial GO
This commit is contained in:
35
cli/new/select_platforms.go
Normal file
35
cli/new/select_platforms.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user