github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/cli/shared.go (about) 1 package cli 2 3 import ( 4 "context" 5 6 "github.com/wawandco/ox/plugins" 7 "github.com/wawandco/ox/plugins/core" 8 ) 9 10 var ( 11 // shared CLI instance, its here to 12 // simplify the API for custom plugins. 13 shared = &cli{ 14 Plugins: plugins.Default, 15 } 16 ) 17 18 // Use specific plugin by adding it to the 19 // cli plugin list. 20 func Use(plugins ...core.Plugin) { 21 shared.Use(plugins...) 22 } 23 24 // Remove a plugin by its name form the CLI 25 // list of plugins. 26 func Remove(names ...string) { 27 shared.Remove(names...) 28 } 29 30 // Clear all the plugins from the CLI 31 // useful when you just want a few plugins 32 // on certain environment. 33 func Clear() { 34 shared.Clear() 35 } 36 37 // Run the CLI. 38 func Run(ctx context.Context, args []string) error { 39 return shared.Run(ctx, args) 40 } 41 42 // Wrap runs cmd/ox/main.go if found, otherwise 43 // it calls cli.Run. 44 func Wrap(ctx context.Context, args []string) error { 45 return shared.Wrap(ctx, args) 46 }