Skip to content

Commit 6f466d9

Browse files
author
Rodrigo Navarro
committed
no-story (feature): Add version command
1 parent d87285c commit 6f466d9

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pkg/cmd/cmd.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"boilerplate"
5+
"fmt"
56
"template"
67

78
"github.com/commit-message-formatter/pkg/git"
@@ -10,39 +11,46 @@ import (
1011

1112
// Root Root cli command
1213
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",
1717
Run: func(cmd *cobra.Command, args []string) {
1818
go git.CheckTree()
1919
message := template.Run()
2020
git.Commit(message)
2121
},
2222
}
2323

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+
2433
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",
2937
Run: func(cmd *cobra.Command, args []string) {
3038
message := template.Run()
3139
git.Amend(message)
3240
},
3341
}
3442

3543
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",
4047
Run: func(cmd *cobra.Command, args []string) {
4148
boilerplate.Create()
4249
},
4350
}
4451

4552
func init() {
53+
Root.AddCommand(version)
4654
Root.AddCommand(boilerplateCMD)
4755
Root.AddCommand(amend)
4856
}

0 commit comments

Comments
 (0)