package main import ( "flag" "fmt" "net/http" "os" ) var base_link string var base_aplus_link string var external_tools_code int var token string var client http.Client var verbose bool func usage() { 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(" -v, --verbose\tprints with verbose output") fmt.Println(" -h, --help\tdisplays this help message") } func main() { initialize() var code string var course int var listall bool var listfav bool var help bool flag.StringVar(&code, "code", "", "5 character attendance code") flag.StringVar(&code, "c", "", "5 character attendance code") flag.IntVar(&course, "course", -1, "canvas course code") flag.IntVar(&course, "C", -1, "canvas course code") flag.BoolVar(&listall, "list", false, "list all canvas courses") flag.BoolVar(&listall, "L", false, "list all canvas courses") flag.BoolVar(&listfav, "listfav", false, "list favorited canvas courses") flag.BoolVar(&listfav, "F", false, "list favorited canvas courses") flag.BoolVar(&verbose, "verbose", false, "verbose output") flag.BoolVar(&verbose, "v", false, "verbose output") flag.BoolVar(&help, "help", false, "view usage message") flag.BoolVar(&help, "h", false, "view usage message") flag.Parse() if code == "" && course == -1 && !listall && !listfav && !help { usage() os.Exit(1) } if listall { _ = list_all_courses(false) os.Exit(0) } if listfav { list_favorite_courses() os.Exit(0) } if help { usage() os.Exit(0) } if len(code) == 5 && course != -1 { fmt.Printf("%d %s\n", course, code) submit_code(course, code) } 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) } else if len(code) == 5 && course == -1 { fmt.Println("Checking which course to send the code to") submit_code_sans_course(code) } }