diff --git a/aplus.go b/aplus.go index 96fbd92..dfc73e1 100644 --- a/aplus.go +++ b/aplus.go @@ -14,7 +14,9 @@ import ( func submit_code(course_code int, attendance_code string) { cur_body := launch_aplus(course_code) - fmt.Printf("%s", cur_body) + if verbose { + 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 @@ -33,10 +35,12 @@ func submit_code(course_code int, attendance_code string) { link_url := current_url + cur_body[link_start:link_end] link_url = html.UnescapeString(link_url) - fmt.Println("!!!") - fmt.Printf("%i %i %i\n", daypanel_start, link_start, link_end) - fmt.Println(link_url) - fmt.Println("!!!") + if verbose { + fmt.Println("!!!") + fmt.Printf("%i %i %i\n", daypanel_start, link_start, link_end) + fmt.Println(link_url) + fmt.Println("!!!") + } resp, _ := client.Get(link_url) body, _ := io.ReadAll(resp.Body) diff --git a/canvas.go b/canvas.go index d781717..2991ebd 100644 --- a/canvas.go +++ b/canvas.go @@ -23,8 +23,10 @@ func initialize() { client = http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { - fmt.Println("Redirected to:", req.URL) - fmt.Println(req.Cookies()) + if verbose { + fmt.Println("Redirected to:", req.URL) + fmt.Println(req.Cookies()) + } return nil }, Jar: jar, diff --git a/main.go b/main.go index 0ebd8f7..3390dbd 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ 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]") @@ -19,6 +20,7 @@ func usage() { 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") } @@ -39,6 +41,8 @@ func main() { 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")