mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-21 17:00:30 -05:00
Switch to getopt library from flag library for flag parsing.
This commit is contained in:
parent
e28dc92307
commit
d425358bd0
2
go.mod
2
go.mod
@ -3,3 +3,5 @@ module codeberg.org/flpolyaplus/aplus
|
|||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
require golang.org/x/net v0.18.0
|
require golang.org/x/net v0.18.0
|
||||||
|
|
||||||
|
require github.com/pborman/getopt v1.1.0 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -1,2 +1,4 @@
|
|||||||
|
github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
|
||||||
|
github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
|
||||||
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
|
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
|
||||||
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||||
|
22
main.go
22
main.go
@ -1,9 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/pborman/getopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var base_link string
|
var base_link string
|
||||||
@ -15,12 +17,18 @@ var client http.Client
|
|||||||
func main() {
|
func main() {
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
code := flag.String("code", "", "Code to enter")
|
code := getopt.StringLong("code", 'c', "", "Code to enter")
|
||||||
course := flag.Int("course", -1, "Canvas course number")
|
course := getopt.IntLong("course", 'C', -1, "Canvas course number")
|
||||||
list_all := flag.Bool("list-all", false, "List all courses")
|
list_all := getopt.BoolLong("list-all", 0, "List all courses")
|
||||||
list_favorites := flag.Bool("list-favorites", false, "List favorite courses")
|
list_favorites := getopt.BoolLong("list-favorites", 0, "List favorite courses")
|
||||||
|
help := getopt.BoolLong("help", 0, "Help")
|
||||||
|
|
||||||
flag.Parse()
|
getopt.Parse()
|
||||||
|
|
||||||
|
if *help {
|
||||||
|
getopt.Usage()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if *list_all {
|
if *list_all {
|
||||||
list_all_courses()
|
list_all_courses()
|
||||||
@ -34,6 +42,4 @@ func main() {
|
|||||||
fmt.Printf("%d %s", *course, *code)
|
fmt.Printf("%d %s", *course, *code)
|
||||||
submit_code(*course, *code)
|
submit_code(*course, *code)
|
||||||
}
|
}
|
||||||
|
|
||||||
submit_code(7329, "asdkl")
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user