github.com/wawandco/oxpecker@v1.5.7-0.20210910201653-5958d4afdd89/lifecycle/fix/fix.go (about) 1 // fix package contains the logics of the fix operations, fix operations 2 // are in charge of adapting our source code to comply with newer versions 3 // of the CLI. 4 package fix 5 6 import ( 7 "context" 8 "fmt" 9 10 "github.com/wawandco/oxpecker/internal/log" 11 "github.com/wawandco/oxpecker/plugins" 12 ) 13 14 //HelpText returns the help Text of build function 15 16 var _ plugins.Command = (*Command)(nil) 17 var _ plugins.PluginReceiver = (*Command)(nil) 18 19 type Command struct { 20 fixers []Fixer 21 } 22 23 func (c Command) Name() string { 24 return "fix" 25 } 26 27 func (c Command) ParentName() string { 28 return "" 29 } 30 31 func (c Command) HelpText() string { 32 return "adapts the source code to comply with newer versions of the CLI" 33 } 34 35 func (c *Command) Run(ctx context.Context, root string, args []string) error { 36 log.Info("Running fix command") 37 38 //Run each of the fixers registered. 39 for _, fixer := range c.fixers { 40 fmt.Printf("Fixer: %v\n", fixer.Name()) 41 } 42 43 return nil 44 } 45 46 func (c *Command) Receive(plugins []plugins.Plugin) { 47 for _, plugin := range plugins { 48 if ptool, ok := plugin.(Fixer); ok { 49 c.fixers = append(c.fixers, ptool) 50 } 51 } 52 }