File tree 7 files changed +12
-24
lines changed
7 files changed +12
-24
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,13 @@ func main() {
45
45
return config .ReadInConfig ()
46
46
}
47
47
48
- cmds := commands .AllCommands (config )
49
- cmdRoot .AddCommand (cmds ... )
48
+ cmdRoot .AddCommand (
49
+ commands .AddCmd (config ),
50
+ commands .InitCmd (config ),
51
+ commands .VersionCmd (config ),
52
+ commands .ConfigCmd (config ),
53
+ commands .FormatCmd (config ),
54
+ )
50
55
51
56
if err := cmdRoot .Execute (); err != nil {
52
57
// nolint: gomnd, gocritic
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import (
15
15
)
16
16
17
17
// nolint: gocognit, funlen, gocritic
18
- func setupAddCmd (config * viper.Viper ) (cmd * cobra.Command ) {
18
+ func AddCmd (config * viper.Viper ) (cmd * cobra.Command ) {
19
19
var (
20
20
input ,
21
21
output ,
Original file line number Diff line number Diff line change @@ -7,19 +7,6 @@ import (
7
7
"github.com/spf13/viper"
8
8
)
9
9
10
- // AllCommands returns all commands supported.
11
- func AllCommands (config * viper.Viper ) (cmds []* cobra.Command ) {
12
- cmds = append (cmds ,
13
- setupVersionCmd (config ),
14
- setupConfigCmd (config ),
15
- setupAddCmd (config ),
16
- setupInitCmd (config ),
17
- setupFormatCmd (config ),
18
- )
19
-
20
- return cmds
21
- }
22
-
23
10
func commonFlags (cmd * cobra.Command , config * viper.Viper ) (* cobra.Command , * viper.Viper ) {
24
11
var (
25
12
urgency , owner string
Original file line number Diff line number Diff line change 5
5
"github.com/spf13/viper"
6
6
)
7
7
8
- func setupConfigCmd (config * viper.Viper ) (cmd * cobra.Command ) {
8
+ func ConfigCmd (config * viper.Viper ) (cmd * cobra.Command ) {
9
9
var pkg string
10
10
cmd = & cobra.Command {
11
11
Use : "config" ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import (
16
16
var ErrTemplateFlags = errors .New ("--template and --template-file are mutually exclusive" )
17
17
18
18
// nolint: funlen, gocritic
19
- func setupFormatCmd (config * viper.Viper ) (cmd * cobra.Command ) {
19
+ func FormatCmd (config * viper.Viper ) (cmd * cobra.Command ) {
20
20
var input ,
21
21
output ,
22
22
pkg ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import (
15
15
// ErrNoTags happens when a repository has no tags.
16
16
var ErrNoTags = errors .New ("no versioned releases found, check the output of `git tag`" )
17
17
18
- func setupInitCmd (config * viper.Viper ) (cmd * cobra.Command ) {
18
+ func InitCmd (config * viper.Viper ) (cmd * cobra.Command ) {
19
19
var output string
20
20
cmd = & cobra.Command {
21
21
Use : "init [PATH]" ,
@@ -31,10 +31,6 @@ func setupInitCmd(config *viper.Viper) (cmd *cobra.Command) {
31
31
"changelog.yml" ,
32
32
"file to save the new changelog to" )
33
33
34
- cmd .PersistentPreRun = func (c * cobra.Command , args []string ) {
35
- cmd .Parent ().PersistentPreRun (c , args )
36
- }
37
-
38
34
cmd .RunE = func (c * cobra.Command , args []string ) (err error ) {
39
35
var (
40
36
repoPath string
Original file line number Diff line number Diff line change 7
7
"github.com/spf13/viper"
8
8
)
9
9
10
- func setupVersionCmd (config * viper.Viper ) (cmd * cobra.Command ) {
10
+ func VersionCmd (config * viper.Viper ) (cmd * cobra.Command ) {
11
11
cmd = & cobra.Command {
12
12
Use : "version" ,
13
13
Short : "display version info" ,
You can’t perform that action at this time.
0 commit comments