@@ -12,14 +12,34 @@ import (
1212)
1313
1414func selectWorkloads (scanner * bufio.Scanner ) ([]Workload , error ) {
15- fmt .Println ("Input the workload id which should be selected, Example : 0,1,2,3" )
15+ fmt .Println ("Input the workload id which should be selected, example : 0,1,2,3; or a range, example 1-9 " )
1616 fmt .Print ("Input: " )
1717
1818 if ! scanner .Scan () {
1919 return nil , fmt .Errorf ("input nothing" )
2020 }
2121 input := scanner .Text ()
22- workloadsIDs := strings .Split (input , "," )
22+
23+ var workloadsIDs []string
24+ if strings .Contains (input , "," ) {
25+ workloadsIDs = strings .Split (input , "," )
26+ }
27+ if strings .Contains (input , "-" ) {
28+ ids := strings .Split (input , "-" )
29+ startIDStr , endIDStr := ids [0 ], ids [1 ]
30+
31+ startID , err := strconv .Atoi (startIDStr )
32+ if err != nil {
33+ return nil , err
34+ }
35+ endID , err := strconv .Atoi (endIDStr )
36+ if err != nil {
37+ return nil , err
38+ }
39+ for i := startID ; i <= endID ; i ++ {
40+ workloadsIDs = append (workloadsIDs , strconv .Itoa (i ))
41+ }
42+ }
2343
2444 selectedWorkloads := make ([]Workload , len (workloadsIDs ))
2545 for i , id := range workloadsIDs {
0 commit comments