2016-02-15 07:09:34 -06:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2016-03-28 14:42:26 -05:00
|
|
|
|
2016-04-19 01:32:23 -05:00
|
|
|
"fmt"
|
2016-02-15 07:09:34 -06:00
|
|
|
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
|
|
|
|
services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
|
|
|
)
|
|
|
|
|
|
|
|
var getPluginss func(path string) []m.InstalledPlugin = services.GetLocalPlugins
|
|
|
|
var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlugin
|
|
|
|
|
|
|
|
func removeCommand(c CommandLine) error {
|
2016-06-24 13:14:58 -05:00
|
|
|
pluginPath := c.PluginDirectory()
|
2016-02-15 07:09:34 -06:00
|
|
|
localPlugins := getPluginss(pluginPath)
|
|
|
|
|
|
|
|
plugin := c.Args().First()
|
|
|
|
if plugin == "" {
|
2016-02-15 09:11:37 -06:00
|
|
|
return errors.New("Missing plugin parameter")
|
2016-02-15 07:09:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range localPlugins {
|
|
|
|
if p.Id == c.Args().First() {
|
|
|
|
removePlugin(pluginPath, p.Id)
|
2016-04-19 01:32:23 -05:00
|
|
|
return nil
|
2016-02-15 07:09:34 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 01:32:23 -05:00
|
|
|
return fmt.Errorf("Could not find plugin named %s", c.Args().First())
|
2016-02-15 07:09:34 -06:00
|
|
|
}
|