github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/base/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 9 "github.com/wawandco/ox/internal/log" 10 "github.com/wawandco/ox/plugins/core" 11 ) 12 13 //HelpText returns the help Text of build function 14 15 var _ core.Command = (*Command)(nil) 16 var _ core.PluginReceiver = (*Command)(nil) 17 18 type Command struct { 19 fixers []Fixer 20 } 21 22 func (c Command) Name() string { 23 return "fix" 24 } 25 26 func (c Command) ParentName() string { 27 return "" 28 } 29 30 func (c Command) HelpText() string { 31 return "adapts the source code to comply with newer versions of the CLI" 32 } 33 34 func (c *Command) Run(ctx context.Context, root string, args []string) error { 35 log.Info("Running fix command") 36 37 //Run each of the fixers registered. 38 for _, fixer := range c.fixers { 39 err := fixer.Fix(ctx, root, args) 40 if err != nil { 41 return err 42 } 43 } 44 45 return nil 46 } 47 48 func (c *Command) Receive(plugins []core.Plugin) { 49 for _, plugin := range plugins { 50 if ptool, ok := plugin.(Fixer); ok { 51 c.fixers = append(c.fixers, ptool) 52 } 53 } 54 }