Skip to content

Commit

Permalink
fix: unexpected splitting (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
TP-O committed Aug 15, 2023
1 parent dfa6b71 commit 05f2658
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -88,9 +90,18 @@ func RunCLI() *Options {
},
},
Action: func(ctx *cli.Context) error {
options.CourseIDs = ctx.StringSlice("course-id")
shouldExit = false
// Fix: https://github.com/TP-O/goer/issues/1
courseIDs := ctx.StringSlice("course-id")
for i := 0; i < len(courseIDs); i++ {
if len(strings.Split(courseIDs[i], "|")) < 10 && i < len(courseIDs[i])-1 {
options.CourseIDs = append(options.CourseIDs, fmt.Sprintf("%s, %s", courseIDs[i], courseIDs[i+1]))
i++
} else {
options.CourseIDs = append(options.CourseIDs, courseIDs[i])
}
}

shouldExit = false
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
logrus.Warn("=======================================================")

// Try to log in again until the registration is ready
for true {
for {
if ok := goer.Login(credentials); ok {
// goer.Greet()

Expand Down

0 comments on commit 05f2658

Please sign in to comment.