summaryrefslogtreecommitdiff
path: root/main.go
blob: 9386b46cb35494a4f2b8784f3e026bba42a03358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main

import (
	"fmt"
	"net/http"
	"os"

	"github.com/pborman/getopt"
)

var base_link string
var token string
var client http.Client

func main() {
	initialize()

	code := getopt.StringLong("code", 'c', "", "Code to enter")
	course := getopt.IntLong("course", 'C', -1, "Canvas course number")
	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")

	getopt.Parse()

	if *help || (*list_all == false && *list_favorites == false && *code == "" && *course == -1) {
		getopt.Usage()
		os.Exit(0)
	}

	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)
	}
}