/
install.go
35 lines (31 loc) · 911 Bytes
/
install.go
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
package cmd
import (
"fmt"
"os"
"os/exec"
"github.com/kitko/commitizen-go/git"
"github.com/spf13/cobra"
)
var InstallCmd = &cobra.Command{
Use: "install",
Short: "Install this tool to git-core as git-cz",
Run: func(cmd *cobra.Command, args []string) {
appFilePath, _ := exec.LookPath(os.Args[0])
if path, err := git.InstallSubCmd(appFilePath, "cz"); err != nil {
fmt.Printf("Install commitizen failed, err=%v\n", err)
} else {
fmt.Printf("Install commitizen to %s\n", path)
}
},
}
var InstallHookCmd = &cobra.Command{
Use: "install-hook",
Short: "Install this tool to ./git/hooks/prepare-commit-msg",
Run: func(cmd *cobra.Command, args []string) {
if err := git.InstallHookCmd(); err != nil {
fmt.Printf("Install commitizen as hook failed, err=%v\n", err)
} else {
fmt.Printf("Successful install commitizen as git hook in .git/hoooks/prepare-commit-msg\n")
}
},
}