summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorvin <git@vineetk.net>2023-11-20 15:41:28 -0500
committervin <git@vineetk.net>2023-11-20 15:50:22 -0500
commit3065b05ed45a04f401e8aec7d770b9e7a22c8ec4 (patch)
tree60fa26f50e6315fd7eed9a2cbbe3caa7c3347344 /main.go
parent6abb8ede02ebe38f1c84b7bdf0d8be96b9997ec1 (diff)
update usage message
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/main.go b/main.go
index 93defd3..0ebd8f7 100644
--- a/main.go
+++ b/main.go
@@ -14,7 +14,12 @@ var token string
14var client http.Client 14var client http.Client
15 15
16func usage() { 16func usage() {
17 fmt.Println("Usage: aplus [--code attendance_code --course course_code] [--list] [--listfav] [--help]") 17 fmt.Println("Usage: aplus --code attendance_code --course course_code [--list] [--listfav] [--help]")
18 fmt.Println(" -c, --code\tfive character attendance code")
19 fmt.Println(" -C, --course\tcanvas course ID")
20 fmt.Println(" -L, --list\tlists canvas courses with name and ID")
21 fmt.Println(" -F, --listfav\tlists favourited canvas courses with name and ID")
22 fmt.Println(" -h, --help\tdisplays this help message")
18} 23}
19 24
20func main() { 25func main() {
@@ -39,35 +44,39 @@ func main() {
39 44
40 flag.Parse() 45 flag.Parse()
41 46
42 if (code == "" && course == -1 && !listall && !listfav) { 47 if code == "" && course == -1 && !listall && !listfav && !help {
43 usage() 48 usage()
44 os.Exit(1) 49 os.Exit(1)
45 } 50 }
46 51
47 if (listall) { 52 if listall {
48 list_all_courses() 53 list_all_courses()
49 os.Exit(0) 54 os.Exit(0)
50 } 55 }
51 56
52 if (listfav) { 57 if listfav {
53 list_favorite_courses() 58 list_favorite_courses()
54 os.Exit(0) 59 os.Exit(0)
55 } 60 }
56 61
57 if (help) { 62 if help {
58 usage() 63 usage()
59 os.Exit(0) 64 os.Exit(0)
60 } 65 }
61 66
62 if (len(code) != 5) { 67 if len(code) == 5 && course != -1 {
63 fmt.Println("Attendance code must be 5 characters long")
64 os.Exit(1)
65 }
66
67 if code != "" && course != -1 {
68 fmt.Printf("%d %s\n", course, code) 68 fmt.Printf("%d %s\n", course, code)
69 submit_code(course, code) 69 submit_code(course, code)
70 } else { 70 } else if code != "" && course == -1 {
71 fmt.Println("Course code not provided")
72 usage()
73 os.Exit(1)
74 } else if code == "" && course != -1 {
75 fmt.Println("Attendance code not provided")
76 usage()
77 os.Exit(1)
78 } else if len(code) != 5 {
79 fmt.Println("Attendance code must be 5 characters long")
71 usage() 80 usage()
72 os.Exit(1) 81 os.Exit(1)
73 } 82 }