summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJuan Roig <jaroig@outlook.com>2023-11-15 03:58:38 -0500
committerJuan Roig <jaroig@outlook.com>2023-11-15 03:58:38 -0500
commitd425358bd0ac54bf9bfe176d5328b2d87fa86f27 (patch)
tree6deb904dab97f22af1faacd476734f8d2812e9e2 /main.go
parente28dc923074ff7445d23cb97a04233f6192a69be (diff)
Switch to getopt library from flag library for flag parsing.
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/main.go b/main.go
index 61bf20f..b46d0c7 100644
--- a/main.go
+++ b/main.go
@@ -1,9 +1,11 @@
1package main 1package main
2 2
3import ( 3import (
4 "flag"
5 "fmt" 4 "fmt"
6 "net/http" 5 "net/http"
6 "os"
7
8 "github.com/pborman/getopt"
7) 9)
8 10
9var base_link string 11var base_link string
@@ -15,12 +17,18 @@ var client http.Client
15func main() { 17func main() {
16 initialize() 18 initialize()
17 19
18 code := flag.String("code", "", "Code to enter") 20 code := getopt.StringLong("code", 'c', "", "Code to enter")
19 course := flag.Int("course", -1, "Canvas course number") 21 course := getopt.IntLong("course", 'C', -1, "Canvas course number")
20 list_all := flag.Bool("list-all", false, "List all courses") 22 list_all := getopt.BoolLong("list-all", 0, "List all courses")
21 list_favorites := flag.Bool("list-favorites", false, "List favorite courses") 23 list_favorites := getopt.BoolLong("list-favorites", 0, "List favorite courses")
24 help := getopt.BoolLong("help", 0, "Help")
25
26 getopt.Parse()
22 27
23 flag.Parse() 28 if *help {
29 getopt.Usage()
30 os.Exit(0)
31 }
24 32
25 if *list_all { 33 if *list_all {
26 list_all_courses() 34 list_all_courses()
@@ -34,6 +42,4 @@ func main() {
34 fmt.Printf("%d %s", *course, *code) 42 fmt.Printf("%d %s", *course, *code)
35 submit_code(*course, *code) 43 submit_code(*course, *code)
36 } 44 }
37
38 submit_code(7329, "asdkl")
39} 45}