@@ -11,28 +11,46 @@ import (
11
11
func getApp () * cli.App {
12
12
createCmd := & cli.Command {
13
13
Name : "create" ,
14
- Usage : "helpers for initializing commitlint" ,
14
+ Usage : "for creating commitlint conf, hooks " ,
15
15
Subcommands : []* cli.Command {
16
16
{
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
+ },
20
26
},
21
27
{
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
31
36
},
32
37
},
33
38
},
34
39
}
35
40
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
+
36
54
lintCmd := & cli.Command {
37
55
Name : "lint" ,
38
56
Usage : "lints commit message" ,
@@ -63,9 +81,14 @@ func getApp() *cli.App {
63
81
}
64
82
65
83
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
+ },
70
93
}
71
94
}
0 commit comments