27
27
type Cli struct {
28
28
rootCmd * cobra.Command
29
29
groupID string
30
+ gitTag string
31
+ gitHash string
30
32
}
31
33
32
- func New () (c * Cli ) {
34
+ func New (gitTag , gitHash string ) (c * Cli ) {
33
35
c = & Cli {
34
36
rootCmd : & cobra.Command {
35
37
Short : "version manager" ,
36
38
Long : "vm <Command> <SubCommand> --flags args..." ,
37
39
},
38
40
groupID : GroupID ,
41
+ gitTag : gitTag ,
42
+ gitHash : gitHash ,
39
43
}
40
44
c .rootCmd .AddGroup (& cobra.Group {ID : c .groupID , Title : "Command list: " })
41
45
c .initiate ()
@@ -60,8 +64,8 @@ func (c *Cli) initiate() {
60
64
})
61
65
62
66
c .rootCmd .AddCommand (& cobra.Command {
63
- Use : "show " ,
64
- Aliases : []string {"sh" , "S " },
67
+ Use : "list " ,
68
+ Aliases : []string {"l " },
65
69
GroupID : GroupID ,
66
70
Short : "Shows the supported applications." ,
67
71
Run : func (cmd * cobra.Command , args []string ) {
@@ -146,7 +150,7 @@ func (c *Cli) initiate() {
146
150
147
151
c .rootCmd .AddCommand (& cobra.Command {
148
152
Use : "local" ,
149
- Aliases : []string {"l " },
153
+ Aliases : []string {"L " },
150
154
GroupID : GroupID ,
151
155
Short : "Shows installed versions for an app." ,
152
156
Long : "Example: vm l go." ,
@@ -247,7 +251,7 @@ func (c *Cli) initiate() {
247
251
Use : "clear-cache" ,
248
252
Aliases : []string {"c" , "cc" },
249
253
GroupID : GroupID ,
250
- Short : "Clear cached zip files for an app." ,
254
+ Short : "Clears cached zip files for an app." ,
251
255
Long : "Example: vm c go" ,
252
256
Run : func (cmd * cobra.Command , args []string ) {
253
257
if len (args ) == 0 {
@@ -260,6 +264,19 @@ func (c *Cli) initiate() {
260
264
}
261
265
},
262
266
})
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
+ })
263
280
}
264
281
265
282
func (that * Cli ) Run () {
0 commit comments