diff --git a/README.md b/README.md index db117a3..99780c3 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,16 @@ -# aplus +# aplus command line utility -This is an aplus cli utility created for students at Florida Polytechnic University to submit their aplus codes through the CLI. +This is an cli utility initially created for students at Florida Polytechnic University to submit their aplus codes. In time, we intend to generalize this utility to all universities. In the meantime however, any students from other universities wishing to use the utility may change the base_link and external_tools_code (you see this in the URL when you navigate to Aplus attendance within your course) variables. ## Usage ### List all courses and canvas course codes -aplus -aplus --list-courses -aplus -l +aplus --list-all ### List favorite courses and canvas course codes aplus --list-favorites -### Enter code immediately for an active code -aplus -c -aplus --code - ### Enter code for a specified course -aplus -c --course -aplus --code --course \ No newline at end of file +aplus --code --course \ No newline at end of file diff --git a/aplus.go b/aplus.go index b9e6a13..a8d4daf 100644 --- a/aplus.go +++ b/aplus.go @@ -12,6 +12,9 @@ import ( func submit_code(course_code int, attendance_code string) { cur_body := launch_aplus(course_code) + + fmt.Printf("%s", cur_body) + current_url := fmt.Sprintf("%s/student/", base_aplus_link) // the links to submit the code for a class is under the dayPanel div daypanel_start := strings.Index(cur_body, "
") diff --git a/go.mod b/go.mod index 10fe00c..732a265 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module codeberg.org/flpolyaplus/aplus go 1.21.3 -require golang.org/x/net v0.18.0 // indirect +require golang.org/x/net v0.18.0 diff --git a/main.go b/main.go index 6e4205e..61bf20f 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,8 @@ package main import ( + "flag" + "fmt" "net/http" ) @@ -13,8 +15,25 @@ var client http.Client func main() { initialize() - course_code := 7326 - submit_code(course_code, "A1B2C") + code := flag.String("code", "", "Code to enter") + course := flag.Int("course", -1, "Canvas course number") + list_all := flag.Bool("list-all", false, "List all courses") + list_favorites := flag.Bool("list-favorites", false, "List favorite courses") - // enter_code() + flag.Parse() + + if *list_all { + list_all_courses() + } + + if *list_favorites { + list_favorite_courses() + } + + if *code != "" && *course != -1 { + fmt.Printf("%d %s", *course, *code) + submit_code(*course, *code) + } + + submit_code(7329, "asdkl") }