@@ -11,28 +11,46 @@ import (
1111func getApp () * cli.App {
1212 createCmd := & cli.Command {
1313 Name : "create" ,
14- Usage : "helpers for initializing commitlint" ,
14+ Usage : "for creating commitlint conf, hooks " ,
1515 Subcommands : []* cli.Command {
1616 {
17- Name : "config" ,
18- Usage : "creates default commitlint.yaml in current directory" ,
19- Action : initConfCallback ,
17+ Name : "config" ,
18+ Usage : "creates commitlint.yaml in current directory" ,
19+ Action : func (ctx * cli.Context ) error {
20+ err := commitlint .DefaultConfToFile (defConfFileName )
21+ if err != nil {
22+ return cli .Exit (err , exitCode )
23+ }
24+ return nil
25+ },
2026 },
2127 {
22- Name : "hook" ,
23- Usage : "creates commit hook and sets git config" ,
24- Action : initHookCallback ,
25- Flags : []cli.Flag {
26- & cli.BoolFlag {
27- Name : "global" ,
28- Aliases : []string {"g" },
29- Usage : "sets git hook config in global`" ,
30- },
28+ Name : "hook" ,
29+ Usage : "creates commit-msg in current directory" ,
30+ Action : func (ctx * cli.Context ) (retErr error ) {
31+ err := commitlint .WriteHookToFile (commitMsgHook )
32+ if err != nil {
33+ return cli .Exit (err , exitCode )
34+ }
35+ return nil
3136 },
3237 },
3338 },
3439 }
3540
41+ initCmd := & cli.Command {
42+ Name : "init" ,
43+ Usage : "setup commitlint for git repos" ,
44+ Action : initCallback ,
45+ Flags : []cli.Flag {
46+ & cli.BoolFlag {
47+ Name : "global" ,
48+ Aliases : []string {"g" },
49+ Usage : "sets git hook config in global" ,
50+ },
51+ },
52+ }
53+
3654 lintCmd := & cli.Command {
3755 Name : "lint" ,
3856 Usage : "lints commit message" ,
@@ -63,9 +81,14 @@ func getApp() *cli.App {
6381 }
6482
6583 return & cli.App {
66- Name : "commitlint" ,
67- Usage : "linter for conventional commits" ,
68- Action : nil ,
69- Commands : []* cli.Command {lintCmd , createCmd , versionCmd },
84+ Name : "commitlint" ,
85+ Usage : "linter for conventional commits" ,
86+ Action : nil ,
87+ Commands : []* cli.Command {
88+ createCmd ,
89+ initCmd ,
90+ lintCmd ,
91+ versionCmd ,
92+ },
7093 }
7194}
0 commit comments