github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/cmds/test/setup.go (about) 1 package test 2 3 import ( 4 "context" 5 6 "github.com/gobuffalo/buffalo-cli/v2/cli/cmds/setup" 7 "github.com/gobuffalo/plugins" 8 "github.com/gobuffalo/plugins/plugcmd" 9 ) 10 11 var _ plugcmd.Namer = &Setup{} 12 var _ plugins.Needer = &Setup{} 13 var _ plugins.Plugin = &Setup{} 14 var _ setup.AfterSetuper = &Setup{} 15 16 type Setup struct { 17 pluginsFn plugins.Feeder 18 } 19 20 func (s Setup) PluginName() string { 21 return "test/setup" 22 } 23 24 func (s Setup) CmdName() string { 25 return "test" 26 } 27 28 func (s *Setup) WithPlugins(f plugins.Feeder) { 29 s.pluginsFn = f 30 } 31 32 func (s Setup) AfterSetup(ctx context.Context, root string, args []string, err error) error { 33 if err != nil { 34 return nil 35 } 36 tc := &Cmd{} 37 if s.pluginsFn != nil { 38 for _, p := range s.pluginsFn() { 39 if t, ok := p.(*Cmd); ok { 40 tc = t 41 break 42 } 43 } 44 } 45 tc.WithPlugins(s.pluginsFn) 46 return tc.Main(ctx, root, args) 47 }