commit 3065b05ed45a04f401e8aec7d770b9e7a22c8ec4
parent 6abb8ede02ebe38f1c84b7bdf0d8be96b9997ec1
Author: vin <git@vineetk.net>
Date: Mon, 20 Nov 2023 15:41:28 -0500
update usage message
Diffstat:
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/aplus.go b/aplus.go
@@ -64,6 +64,7 @@ func launch_aplus(course_code int) string {
err := init_aplus_toolid(course_code)
if err != nil {
fmt.Println("Failed to get A+ base URL and tool ID. Try again with a different course code.")
+ fmt.Printf("Error: %s\n", err)
os.Exit(1)
}
diff --git a/main.go b/main.go
@@ -14,7 +14,12 @@ var token string
var client http.Client
func usage() {
- fmt.Println("Usage: aplus [--code attendance_code --course course_code] [--list] [--listfav] [--help]")
+ fmt.Println("Usage: aplus --code attendance_code --course course_code [--list] [--listfav] [--help]")
+ fmt.Println(" -c, --code\tfive character attendance code")
+ fmt.Println(" -C, --course\tcanvas course ID")
+ fmt.Println(" -L, --list\tlists canvas courses with name and ID")
+ fmt.Println(" -F, --listfav\tlists favourited canvas courses with name and ID")
+ fmt.Println(" -h, --help\tdisplays this help message")
}
func main() {
@@ -39,35 +44,39 @@ func main() {
flag.Parse()
- if (code == "" && course == -1 && !listall && !listfav) {
+ if code == "" && course == -1 && !listall && !listfav && !help {
usage()
os.Exit(1)
}
- if (listall) {
+ if listall {
list_all_courses()
os.Exit(0)
}
- if (listfav) {
+ if listfav {
list_favorite_courses()
os.Exit(0)
}
- if (help) {
+ if help {
usage()
os.Exit(0)
}
- if (len(code) != 5) {
- fmt.Println("Attendance code must be 5 characters long")
- os.Exit(1)
- }
-
- if code != "" && course != -1 {
+ if len(code) == 5 && course != -1 {
fmt.Printf("%d %s\n", course, code)
submit_code(course, code)
- } else {
+ } else if code != "" && course == -1 {
+ fmt.Println("Course code not provided")
+ usage()
+ os.Exit(1)
+ } else if code == "" && course != -1 {
+ fmt.Println("Attendance code not provided")
+ usage()
+ os.Exit(1)
+ } else if len(code) != 5 {
+ fmt.Println("Attendance code must be 5 characters long")
usage()
os.Exit(1)
}