@@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"boilerplate"
5
+ "fmt"
5
6
"template"
6
7
7
8
"github.com/commit-message-formatter/pkg/git"
@@ -10,39 +11,46 @@ import (
10
11
11
12
// Root Root cli command
12
13
var Root = &cobra.Command{
13
- Use: "cmf",
14
- Short: "Commit Message Formatter",
15
- Long: "Generate custom commit message for your repo and standarize your commits log",
16
- PreRun: func(cmd *cobra.Command, args []string) {},
14
+ Use: "cmf",
15
+ Short: "Commit Message Formatter",
16
+ Long: "Generate custom commit message for your repo and standarize your commits log",
17
17
Run: func(cmd *cobra.Command, args []string) {
18
18
go git.CheckTree()
19
19
message := template.Run()
20
20
git.Commit(message)
21
21
},
22
22
}
23
23
24
+ var version = &cobra.Command{
25
+ Use: "version",
26
+ Short: "Version cmf",
27
+ Long: "Display version of commit message formatter",
28
+ Run: func(cmd *cobra.Command, args []string) {
29
+ fmt.Println("CMF - Commit Message Formatter v2.0")
30
+ },
31
+ }
32
+
24
33
var amend = &cobra.Command{
25
- Use: "amend",
26
- Short: "Amend commit message",
27
- Long: "Amend last commit message",
28
- PreRun: func(cmd *cobra.Command, args []string) {},
34
+ Use: "amend",
35
+ Short: "Amend commit message",
36
+ Long: "Amend last commit message",
29
37
Run: func(cmd *cobra.Command, args []string) {
30
38
message := template.Run()
31
39
git.Amend(message)
32
40
},
33
41
}
34
42
35
43
var boilerplateCMD = &cobra.Command{
36
- Use: "init",
37
- Short: "Create configuration file",
38
- Long: "Create .cmf.yaml configuration file",
39
- PreRun: func(cmd *cobra.Command, args []string) {},
44
+ Use: "init",
45
+ Short: "Create configuration file",
46
+ Long: "Create .cmf.yaml configuration file",
40
47
Run: func(cmd *cobra.Command, args []string) {
41
48
boilerplate.Create()
42
49
},
43
50
}
44
51
45
52
func init() {
53
+ Root.AddCommand(version)
46
54
Root.AddCommand(boilerplateCMD)
47
55
Root.AddCommand(amend)
48
56
}
0 commit comments