@@ -3,27 +3,40 @@ package cmd
33import (
44 "github.com/meinto/glow"
55
6+ "github.com/meinto/glow/pkg/cli/cmd/internal/command"
67 "github.com/meinto/glow/pkg/cli/cmd/internal/util"
78 "github.com/spf13/cobra"
89 "github.com/spf13/viper"
910)
1011
11- func init () {
12- RootCmd . Cmd (). AddCommand ( featureCmd )
12+ type FeatureCommand struct {
13+ command. Service
1314}
1415
15- var featureCmd = & cobra.Command {
16- Use : "feature" ,
17- Short : "create a feature branch" ,
18- Args : cobra .MinimumNArgs (1 ),
19- Run : func (cmd * cobra.Command , args []string ) {
20- featureName := args [0 ]
16+ func (cmd * FeatureCommand ) PostSetup (parent command.Service ) command.Service {
17+ parent .Add (cmd )
18+ return cmd
19+ }
20+
21+ var featureCmd = SetupFeatureCommand (RootCmd )
22+
23+ func SetupFeatureCommand (parent command.Service ) command.Service {
24+ return command .Setup (& FeatureCommand {
25+ & command.Command {
26+ Command : & cobra.Command {
27+ Use : "feature" ,
28+ Short : "create a feature branch" ,
29+ Args : cobra .MinimumNArgs (1 ),
30+ },
31+ Run : func (cmd command.Service , args []string ) {
32+ featureName := args [0 ]
2133
22- feature , err := glow .NewFeature (viper .GetString ("author" ), featureName )
23- util .ExitOnError (err )
34+ feature , err := glow .NewFeature (viper .GetString ("author" ), featureName )
35+ util .ExitOnError (err )
2436
25- g , err := util .GetGitClient ()
26- util .ExitOnError (g .Create (feature , rootCmdOptions .SkipChecks ))
27- util .ExitOnError (g .Checkout (feature ))
28- },
37+ util .ExitOnError (cmd .GitClient ().Create (feature , rootCmdOptions .SkipChecks ))
38+ util .ExitOnError (cmd .GitClient ().Checkout (feature ))
39+ },
40+ },
41+ })
2942}
0 commit comments