File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 88 "os"
99 "os/exec"
1010 "runtime"
11+ "sort"
1112 "strconv"
1213 "syscall"
1314 "time"
@@ -57,25 +58,28 @@ func main() {
5758 }
5859
5960 if * chosenOrgName == "" {
60- fmt .Println ("Available organizations: " )
61- i := 1
61+ orgNames := make ([]string , 0 , len (orgs ))
6262 for name := range orgs {
63- fmt .Println (i , "." , name )
64- i ++
63+ orgNames = append (orgNames , name )
64+ }
65+
66+ sort .Strings (orgNames ) // Optional: sort for consistent ordering
67+
68+ fmt .Println ("Available organizations: " )
69+ for i , name := range orgNames {
70+ fmt .Println (i + 1 , "." , name )
6571 }
6672
6773 fmt .Print ("Choose an organization by entering the corresponding number: " )
6874 scanner .Scan ()
6975 chosenNumber , _ := strconv .Atoi (scanner .Text ())
7076
71- i = 1
72- for name := range orgs {
73- if i == chosenNumber {
74- * chosenOrgName = name
75- break
76- }
77- i ++
77+ if chosenNumber < 1 || chosenNumber > len (orgNames ) {
78+ fmt .Println ("Invalid selection." )
79+ return
7880 }
81+
82+ * chosenOrgName = orgNames [chosenNumber - 1 ]
7983 }
8084
8185 if * chosenDuration == 0 {
You can’t perform that action at this time.
0 commit comments