mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-21 17:00:30 -05:00
update usage message
This commit is contained in:
parent
6abb8ede02
commit
3065b05ed4
1
aplus.go
1
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)
|
||||
}
|
||||
|
||||
|
33
main.go
33
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user