diff options
| author | vin <git@vineetk.net> | 2024-01-16 14:50:19 -0500 |
|---|---|---|
| committer | vin <git@vineetk.net> | 2024-01-16 14:50:19 -0500 |
| commit | 627120b31f22f2f286fc2552f4586f29e7e1762c (patch) | |
| tree | d5fb12c10aaf44044f239c44fa99724908e5d5ab /main.go | |
| parent | 4d0051f5165c5455f8780a163cfb225754aaa7d9 (diff) | |
add timetable function
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 15 |
1 files changed, 14 insertions, 1 deletions
| @@ -16,11 +16,12 @@ var client http.Client | |||
| 16 | var verbose bool | 16 | var verbose bool |
| 17 | 17 | ||
| 18 | func usage() { | 18 | func usage() { |
| 19 | fmt.Println("Usage: aplus --code attendance_code --course course_code [--list] [--listfav] [--help]") | 19 | fmt.Println("Usage: aplus --code attendance_code --course course_code [--list] [--listfav] [--timetable] [--help]") |
| 20 | fmt.Println(" -c, --code\tfive character attendance code") | 20 | fmt.Println(" -c, --code\tfive character attendance code") |
| 21 | fmt.Println(" -C, --course\tcanvas course ID") | 21 | fmt.Println(" -C, --course\tcanvas course ID") |
| 22 | fmt.Println(" -L, --list\tlists canvas courses with name and ID") | 22 | fmt.Println(" -L, --list\tlists canvas courses with name and ID") |
| 23 | fmt.Println(" -F, --listfav\tlists favourited canvas courses with name and ID") | 23 | fmt.Println(" -F, --listfav\tlists favourited canvas courses with name and ID") |
| 24 | fmt.Println(" -t, --timetable\tlists the class sessions in a course") | ||
| 24 | fmt.Println(" -v, --verbose\tprints with verbose output") | 25 | fmt.Println(" -v, --verbose\tprints with verbose output") |
| 25 | fmt.Println(" -h, --help\tdisplays this help message") | 26 | fmt.Println(" -h, --help\tdisplays this help message") |
| 26 | fmt.Println(" -p, --profile\twrites cpu profile to a file") | 27 | fmt.Println(" -p, --profile\twrites cpu profile to a file") |
| @@ -33,6 +34,7 @@ func main() { | |||
| 33 | var course int | 34 | var course int |
| 34 | var listall bool | 35 | var listall bool |
| 35 | var listfav bool | 36 | var listfav bool |
| 37 | var timetable_ bool | ||
| 36 | var help bool | 38 | var help bool |
| 37 | var cpuprofile string | 39 | var cpuprofile string |
| 38 | 40 | ||
| @@ -44,6 +46,8 @@ func main() { | |||
| 44 | flag.BoolVar(&listall, "L", false, "list all canvas courses") | 46 | flag.BoolVar(&listall, "L", false, "list all canvas courses") |
| 45 | flag.BoolVar(&listfav, "listfav", false, "list favorited canvas courses") | 47 | flag.BoolVar(&listfav, "listfav", false, "list favorited canvas courses") |
| 46 | flag.BoolVar(&listfav, "F", false, "list favorited canvas courses") | 48 | flag.BoolVar(&listfav, "F", false, "list favorited canvas courses") |
| 49 | flag.BoolVar(&timetable_, "t", false, "lists the class sessions in a course") | ||
| 50 | flag.BoolVar(&timetable_, "timetable", false, "lists the class sessions in a course") | ||
| 47 | flag.BoolVar(&verbose, "verbose", false, "verbose output") | 51 | flag.BoolVar(&verbose, "verbose", false, "verbose output") |
| 48 | flag.BoolVar(&verbose, "v", false, "verbose output") | 52 | flag.BoolVar(&verbose, "v", false, "verbose output") |
| 49 | flag.BoolVar(&help, "help", false, "view usage message") | 53 | flag.BoolVar(&help, "help", false, "view usage message") |
| @@ -84,6 +88,15 @@ func main() { | |||
| 84 | os.Exit(0) | 88 | os.Exit(0) |
| 85 | } | 89 | } |
| 86 | 90 | ||
| 91 | if course != -1 && timetable_ { | ||
| 92 | timetable(course) | ||
| 93 | os.Exit(0) | ||
| 94 | } else if course == -1 && timetable_ { | ||
| 95 | fmt.Println("Course code required for timetable") | ||
| 96 | usage() | ||
| 97 | os.Exit(1) | ||
| 98 | } | ||
| 99 | |||
| 87 | if help { | 100 | if help { |
| 88 | usage() | 101 | usage() |
| 89 | os.Exit(0) | 102 | os.Exit(0) |
