Skip to content

Commit ed74447

Browse files
committed
tags
1 parent f0fabb9 commit ed74447

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ cmd/vm/vm.exe
2626
build_win.sh
2727
.DS_Store
2828
build_linux.sh
29+
build/*64
30+
build/*.zip

build/build.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"arch_os_list": [
3+
"darwin/amd64",
4+
"darwin/arm64",
5+
"linux/amd64",
6+
"linux/arm64",
7+
"windows/amd64",
8+
"windows/arm64"
9+
],
10+
"build_args": [
11+
"-ldflags",
12+
"-X main.GitTag=$(git describe --abbrev=0 --tags) -X main.GitHash=$(git show -s --format=%H) -s -w",
13+
"./cmd/vm/"
14+
],
15+
"compress": true
16+
}

cmd/cmd.go

+22-5
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ CLIs
2727
type Cli struct {
2828
rootCmd *cobra.Command
2929
groupID string
30+
gitTag string
31+
gitHash string
3032
}
3133

32-
func New() (c *Cli) {
34+
func New(gitTag, gitHash string) (c *Cli) {
3335
c = &Cli{
3436
rootCmd: &cobra.Command{
3537
Short: "version manager",
3638
Long: "vm <Command> <SubCommand> --flags args...",
3739
},
3840
groupID: GroupID,
41+
gitTag: gitTag,
42+
gitHash: gitHash,
3943
}
4044
c.rootCmd.AddGroup(&cobra.Group{ID: c.groupID, Title: "Command list: "})
4145
c.initiate()
@@ -60,8 +64,8 @@ func (c *Cli) initiate() {
6064
})
6165

6266
c.rootCmd.AddCommand(&cobra.Command{
63-
Use: "show",
64-
Aliases: []string{"sh", "S"},
67+
Use: "list",
68+
Aliases: []string{"l"},
6569
GroupID: GroupID,
6670
Short: "Shows the supported applications.",
6771
Run: func(cmd *cobra.Command, args []string) {
@@ -146,7 +150,7 @@ func (c *Cli) initiate() {
146150

147151
c.rootCmd.AddCommand(&cobra.Command{
148152
Use: "local",
149-
Aliases: []string{"l"},
153+
Aliases: []string{"L"},
150154
GroupID: GroupID,
151155
Short: "Shows installed versions for an app.",
152156
Long: "Example: vm l go.",
@@ -247,7 +251,7 @@ func (c *Cli) initiate() {
247251
Use: "clear-cache",
248252
Aliases: []string{"c", "cc"},
249253
GroupID: GroupID,
250-
Short: "Clear cached zip files for an app.",
254+
Short: "Clears cached zip files for an app.",
251255
Long: "Example: vm c go",
252256
Run: func(cmd *cobra.Command, args []string) {
253257
if len(args) == 0 {
@@ -260,6 +264,19 @@ func (c *Cli) initiate() {
260264
}
261265
},
262266
})
267+
268+
c.rootCmd.AddCommand(&cobra.Command{
269+
Use: "version",
270+
Aliases: []string{"v"},
271+
GroupID: GroupID,
272+
Short: "Shows version info of version-manager.",
273+
Run: func(cmd *cobra.Command, args []string) {
274+
if len(c.gitHash) > 7 {
275+
c.gitHash = c.gitHash[:7]
276+
}
277+
fmt.Printf("%s(%s)\n", c.gitTag, c.gitHash)
278+
},
279+
})
263280
}
264281

265282
func (that *Cli) Run() {

cmd/vm/manager.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ import (
55
_ "github.com/gvcgo/version-manager/pkgs/conf"
66
)
77

8+
var (
9+
GitTag string
10+
GitHash string
11+
)
12+
813
/*
914
To be compiled.
1015
*/
1116
func main() {
1217
// os.Setenv(conf.VMReverseProxyEnvName, "https://gvc.1710717.xyz/proxy/")
13-
cli := cmd.New()
18+
cli := cmd.New(GitTag, GitHash)
1419
cli.Run()
1520
}

0 commit comments

Comments
 (0)