2023-10-27 19:02:38 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-11-14 22:42:25 -05:00
|
|
|
"fmt"
|
2023-10-27 19:02:38 -04:00
|
|
|
"net/http"
|
2023-11-15 03:58:38 -05:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/pborman/getopt"
|
2023-10-27 19:02:38 -04:00
|
|
|
)
|
|
|
|
|
2023-11-07 00:21:48 -05:00
|
|
|
var base_link string
|
|
|
|
var token string
|
2023-11-13 02:08:03 -05:00
|
|
|
var client http.Client
|
2023-11-07 00:21:48 -05:00
|
|
|
|
2023-10-27 19:02:38 -04:00
|
|
|
func main() {
|
2023-11-07 00:21:48 -05:00
|
|
|
initialize()
|
2023-11-04 01:55:30 -04:00
|
|
|
|
2023-11-15 03:58:38 -05:00
|
|
|
code := getopt.StringLong("code", 'c', "", "Code to enter")
|
|
|
|
course := getopt.IntLong("course", 'C', -1, "Canvas course number")
|
2023-11-15 13:20:19 -05:00
|
|
|
list_all := getopt.BoolLong("list-all", 'L', "List all courses")
|
|
|
|
list_favorites := getopt.BoolLong("list-favorites", 'F', "List favorite courses")
|
|
|
|
help := getopt.BoolLong("help", 'h', "Help")
|
2023-11-15 03:58:38 -05:00
|
|
|
|
|
|
|
getopt.Parse()
|
2023-10-30 17:58:38 -04:00
|
|
|
|
2023-11-15 13:20:19 -05:00
|
|
|
if *help || (*list_all == false && *list_favorites == false && *code == "" && *course == -1) {
|
2023-11-15 03:58:38 -05:00
|
|
|
getopt.Usage()
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
2023-11-14 22:42:25 -05:00
|
|
|
|
|
|
|
if *list_all {
|
|
|
|
list_all_courses()
|
|
|
|
}
|
|
|
|
|
|
|
|
if *list_favorites {
|
|
|
|
list_favorite_courses()
|
|
|
|
}
|
|
|
|
|
|
|
|
if *code != "" && *course != -1 {
|
|
|
|
fmt.Printf("%d %s", *course, *code)
|
|
|
|
submit_code(*course, *code)
|
|
|
|
}
|
2023-11-04 01:55:30 -04:00
|
|
|
}
|