github.com/singlemusic/buffalo@v0.16.30/buffalo/cmd/plugins/remove.go (about) 1 package plugins 2 3 import ( 4 "context" 5 "fmt" 6 "path" 7 "strings" 8 9 "github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx" 10 "github.com/gobuffalo/buffalo/plugins/plugdeps" 11 "github.com/gobuffalo/genny/v2" 12 "github.com/gobuffalo/meta" 13 "github.com/spf13/cobra" 14 ) 15 16 var removeOptions = struct { 17 dryRun bool 18 vendor bool 19 }{} 20 21 var removeCmd = &cobra.Command{ 22 Use: "remove", 23 Short: "removes plugin from config/buffalo-plugins.toml", 24 RunE: func(cmd *cobra.Command, args []string) error { 25 if len(args) == 0 { 26 return fmt.Errorf("you must specify at least one package") 27 } 28 run := genny.WetRunner(context.Background()) 29 if removeOptions.dryRun { 30 run = genny.DryRunner(context.Background()) 31 } 32 33 app := meta.New(".") 34 plugs, err := plugdeps.List(app) 35 if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) { 36 return err 37 } 38 39 for _, a := range args { 40 a = strings.TrimSpace(a) 41 bin := path.Base(a) 42 plugs.Remove(plugdeps.Plugin{ 43 Binary: bin, 44 GoGet: a, 45 }) 46 } 47 48 run.WithRun(NewEncodePluginsRunner(app, plugs)) 49 return run.Run() 50 }, 51 } 52 53 func init() { 54 removeCmd.Flags().BoolVarP(&removeOptions.dryRun, "dry-run", "d", false, "dry run") 55 removeCmd.Flags().BoolVar(&removeOptions.vendor, "vendor", false, "will install plugin binaries into ./plugins [WINDOWS not currently supported]") 56 }