-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.go
58 lines (50 loc) · 1.28 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"os"
"github.com/daleyshek/poster/common"
)
func main() {
common.Init()
cli()
common.ServeHTTP()
select {}
}
// 命令行测试
func cli() {
cliMode := flag.Bool("cli", false, "是否使用cli mode")
imageURL := flag.String("imageURL", "", "图片资源")
title := flag.String("title", "", "标题")
content := flag.String("content", "", "内容")
scene := flag.String("scene", "", "场景值")
page := flag.String("page", "", "小程序页面")
width := flag.Int("width", 480, "小程序码的尺寸")
flag.Parse()
if *cliMode == false {
return
}
qr := common.QRCodeReq{Scene: *scene, Page: *page, Width: *width}
// 获取小程序码保存到本地
qrcodeName, err := common.RequestQRCode(qr, "", "")
if err != nil {
fmt.Println("获取小程序码失败", err)
os.Exit(1)
}
// 生成海报
style := common.Style{
ImageURL: *imageURL,
QRCodeURL: common.C.OutputDIR + qrcodeName,
Title: *title,
Content: *content,
}
postName, err := common.DrawPoster(style)
if err != nil {
fmt.Println("海报生成失败", err)
os.Exit(1)
}
fmt.Println("运行成功")
fmt.Println("小程序码文件", qrcodeName)
fmt.Println("海报文件", postName)
os.Exit(0)
}