-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
45 lines (37 loc) · 913 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"ecnu-datasync-cli/g"
"flag"
"fmt"
)
func main() {
version := flag.Bool("v", false, "show version")
clientId := flag.String("c", "", "oauth2 client_id")
clientSecret := flag.String("s", "", "oauth2 client_id")
apiPath := flag.String("a", "", "api path")
output := flag.String("o", "", "output file")
cfg := flag.String("config", "", "configuration file")
flag.Parse()
if *version {
fmt.Println(g.VERSION)
return
}
if *cfg != "" {
g.ParseConfig(*cfg)
if err := g.SyncWithConfig(); err != nil {
fmt.Println(err)
return
}
return
}
if *apiPath != "" && *clientSecret != "" && *clientId != "" && *output != "" {
if err := g.SyncWithoutConfig(clientId, clientSecret, output, apiPath); err != nil {
fmt.Println(err)
return
}
return
}
fmt.Println("参数填写不完整,请填写完整参数")
fmt.Println("Usage :")
flag.PrintDefaults()
}