()
| 175 | } |
| 176 | |
| 177 | func newHookCmd() *cli.Command { |
| 178 | return &cli.Command{ |
| 179 | Name: "hook", |
| 180 | Usage: "Create the commit-msg git hook", |
| 181 | Flags: []cli.Flag{ |
| 182 | &cli.BoolFlag{ |
| 183 | Name: "replace", |
| 184 | Aliases: []string{"r"}, |
| 185 | Usage: "Overwrite existing hook files", |
| 186 | }, |
| 187 | &cli.StringFlag{ |
| 188 | Name: "hookspath", |
| 189 | Aliases: []string{"p"}, |
| 190 | Usage: "Where to write hook files (default: .commitlint/hooks)", |
| 191 | }, |
| 192 | }, |
| 193 | Action: func(ctx *cli.Context) error { |
| 194 | isReplace := ctx.Bool("replace") |
| 195 | hooksPath := ctx.String("hookspath") |
| 196 | err := hookCreate(hooksPath, isReplace) |
| 197 | if err != nil { |
| 198 | if isHookExists(err) { |
| 199 | fmt.Println("hook files already exist") |
| 200 | fmt.Println("use --replace to overwrite them") |
| 201 | return nil |
| 202 | } |
| 203 | return err |
| 204 | } |
| 205 | fmt.Println("hooks created") |
| 206 | return nil |
| 207 | }, |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | func newRemoveCmd() *cli.Command { |
| 212 | return &cli.Command{ |
no test coverage detected