-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 694 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
46
package main
import (
"fmt"
"os"
"strings"
"uimg/api"
"uimg/model"
)
func main() {
args := os.Args
if len(args) == 1 || args[1] == "-h" {
fmt.Println("Example usage:")
fmt.Println(" uimg -i ")
fmt.Println(" uimg /1.png /2.jpg")
return
}
if args[1] == "-i" {
model.InitConfig()
return
}
filesNames := args[1:]
c := model.GetConfig()
if c == nil || c.Host == "" || c.Token == "" {
fmt.Println("please init: uimg -i")
return
}
fmt.Println(filesNames)
for _, f := range filesNames {
if strings.HasPrefix(f, "http") {
fmt.Println(f)
} else {
status, imgUrl := api.UploadImg(f, c.Token, c.Host)
if status {
fmt.Println(imgUrl)
}
}
}
}