mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-22 09:20:30 -05:00
add verbose flag
This commit is contained in:
parent
3065b05ed4
commit
6b0ed0f177
4
aplus.go
4
aplus.go
@ -14,7 +14,9 @@ import (
|
|||||||
func submit_code(course_code int, attendance_code string) {
|
func submit_code(course_code int, attendance_code string) {
|
||||||
cur_body := launch_aplus(course_code)
|
cur_body := launch_aplus(course_code)
|
||||||
|
|
||||||
|
if verbose {
|
||||||
fmt.Printf("%s", cur_body)
|
fmt.Printf("%s", cur_body)
|
||||||
|
}
|
||||||
|
|
||||||
current_url := fmt.Sprintf("%s/student/", base_aplus_link)
|
current_url := fmt.Sprintf("%s/student/", base_aplus_link)
|
||||||
// the links to submit the code for a class is under the dayPanel div
|
// 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 := current_url + cur_body[link_start:link_end]
|
||||||
link_url = html.UnescapeString(link_url)
|
link_url = html.UnescapeString(link_url)
|
||||||
|
|
||||||
|
if verbose {
|
||||||
fmt.Println("!!!")
|
fmt.Println("!!!")
|
||||||
fmt.Printf("%i %i %i\n", daypanel_start, link_start, link_end)
|
fmt.Printf("%i %i %i\n", daypanel_start, link_start, link_end)
|
||||||
fmt.Println(link_url)
|
fmt.Println(link_url)
|
||||||
fmt.Println("!!!")
|
fmt.Println("!!!")
|
||||||
|
}
|
||||||
|
|
||||||
resp, _ := client.Get(link_url)
|
resp, _ := client.Get(link_url)
|
||||||
body, _ := io.ReadAll(resp.Body)
|
body, _ := io.ReadAll(resp.Body)
|
||||||
|
@ -23,8 +23,10 @@ func initialize() {
|
|||||||
|
|
||||||
client = http.Client{
|
client = http.Client{
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
if verbose {
|
||||||
fmt.Println("Redirected to:", req.URL)
|
fmt.Println("Redirected to:", req.URL)
|
||||||
fmt.Println(req.Cookies())
|
fmt.Println(req.Cookies())
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Jar: jar,
|
Jar: jar,
|
||||||
|
4
main.go
4
main.go
@ -12,6 +12,7 @@ var base_aplus_link string
|
|||||||
var external_tools_code int
|
var external_tools_code int
|
||||||
var token string
|
var token string
|
||||||
var client http.Client
|
var client http.Client
|
||||||
|
var verbose bool
|
||||||
|
|
||||||
func usage() {
|
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]")
|
||||||
@ -19,6 +20,7 @@ func usage() {
|
|||||||
fmt.Println(" -C, --course\tcanvas course ID")
|
fmt.Println(" -C, --course\tcanvas course ID")
|
||||||
fmt.Println(" -L, --list\tlists canvas courses with name and 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(" -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")
|
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(&listall, "L", false, "list all canvas courses")
|
||||||
flag.BoolVar(&listfav, "listfav", false, "list favorited canvas courses")
|
flag.BoolVar(&listfav, "listfav", false, "list favorited canvas courses")
|
||||||
flag.BoolVar(&listfav, "F", 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, "help", false, "view usage message")
|
||||||
flag.BoolVar(&help, "h", false, "view usage message")
|
flag.BoolVar(&help, "h", false, "view usage message")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user