-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (51 loc) · 1.57 KB
/
main.go
File metadata and controls
64 lines (51 loc) · 1.57 KB
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
59
60
61
62
63
64
//go:generate goversioninfo
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/twgh/xc/build"
"github.com/twgh/xc/dlldownload"
"github.com/twgh/xc/get"
"github.com/twgh/xc/zipdownload"
)
func main() {
var rootCmd = &cobra.Command{
Use: "xc",
Short: "xc 是一个 xcgui 助手类型的命令行工具",
Long: `xc 是一个 xcgui 助手类型的命令行工具, 功能包括给项目添加 xcgui、编译程序、下载 xcgui 和 example 仓库的源码、下载 xcgui.dll 文件等。
使用方法:
xc [command]
可用命令:
get 执行 go get -u github.com/twgh/xcgui
build 执行 go build -ldflags="-s -w -H windowsgui" -trimpath
zipdownload 下载并解压 xcgui 和 example 仓库的源码 ZIP
dlldownload 下载 xcgui.dll 文件
version 显示版本信息
help 显示命令帮助信息
使用 "xc [command] --help" 获取更多关于某个命令的信息。`,
}
// 添加版本命令
var versionCmd = &cobra.Command{
Use: "version",
Short: "显示版本信息",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("xc version 0.0.3")
},
}
// 添加 DLL 下载命令
rootCmd.AddCommand(dlldownload.NewCommand())
// 添加 ZIP 下载命令
rootCmd.AddCommand(zipdownload.NewCommand())
// 添加 get 命令
rootCmd.AddCommand(get.NewCommand())
// 添加 build 命令
rootCmd.AddCommand(build.NewCommand())
// 添加版本命令
rootCmd.AddCommand(versionCmd)
// 执行根命令
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}