remove_command.go 596 B

1234567891011121314151617181920212223242526272829303132
  1. package commands
  2. import (
  3. "errors"
  4. "fmt"
  5. "strings"
  6. services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
  7. )
  8. var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlugin
  9. func removeCommand(c CommandLine) error {
  10. pluginPath := c.PluginDirectory()
  11. plugin := c.Args().First()
  12. if plugin == "" {
  13. return errors.New("Missing plugin parameter")
  14. }
  15. err := removePlugin(pluginPath, plugin)
  16. if err != nil {
  17. if strings.Contains(err.Error(), "no such file or directory") {
  18. return fmt.Errorf("Plugin does not exist")
  19. }
  20. return err
  21. }
  22. return nil
  23. }