Skip to content

Commit e6448e4

Browse files
committed
feat: add enter session prompt
1 parent 7c714e7 commit e6448e4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

main.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ import (
99
"github.com/jedib0t/go-pretty/v6/table"
1010
)
1111

12+
1213
func main() {
13-
var ids []string
14-
url := "https://e3.nycu.edu.tw/"
1514
var session string
15+
var only_in_progress bool
1616
flag.StringVar(&session, "session", "", "Set session cookie")
1717
flag.StringVar(&session, "s", "", "Set session cookie")
18-
var only_in_progress bool
1918
flag.BoolVar(&only_in_progress, "only-in-progress", false, "Only show in progress homework.")
2019
flag.Parse()
21-
if session == "" {
22-
fmt.Println("Session cookie must be provided.")
23-
os.Exit(1)
20+
for session == "" {
21+
fmt.Print("Please enter your session (the cookie `MoodleSession`): ")
22+
fmt.Scanln(&session)
2423
}
24+
fmt.Println("Fecthing the data, please wait...")
25+
26+
var ids []string
27+
url := "https://e3.nycu.edu.tw/"
2528

2629
collector := colly.NewCollector()
2730
collector.OnResponse(func(r *colly.Response){
@@ -61,7 +64,7 @@ func main() {
6164
})
6265
var submitted [5][]string
6366
var overdue [5][]string
64-
if !only_in_progress{
67+
if !only_in_progress {
6568
// submitted
6669
collector.OnHTML("#news-view-nofile2-tobegraded-in-progress tbody tr .instancename", func(e *colly.HTMLElement) {
6770
// HW name

0 commit comments

Comments
 (0)