update usage message

This commit is contained in:
Vineet K 2023-11-20 15:41:28 -05:00
parent 6abb8ede02
commit 3065b05ed4
2 changed files with 22 additions and 12 deletions

View File

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

33
main.go
View File

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