2016-02-15 21:09:34 +08:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2016-03-29 03:42:26 +08:00
|
|
|
|
2016-02-15 21:09:34 +08:00
|
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
|
|
|
|
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-03-29 03:42:26 +08:00
|
|
|
pluginPath := c.GlobalString("pluginsDir")
|
2016-02-15 21:09:34 +08:00
|
|
|
localPlugins := getPluginss(pluginPath)
|
|
|
|
|
|
|
|
log.Info("remove!\n")
|
|
|
|
|
|
|
|
plugin := c.Args().First()
|
|
|
|
log.Info("plugin: " + plugin + "\n")
|
|
|
|
if plugin == "" {
|
2016-02-15 23:11:37 +08:00
|
|
|
return errors.New("Missing plugin parameter")
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("plugins : \n%v\n", localPlugins)
|
|
|
|
|
|
|
|
for _, p := range localPlugins {
|
|
|
|
if p.Id == c.Args().First() {
|
2016-02-15 23:11:37 +08:00
|
|
|
log.Infof("removing plugin %s", p.Id)
|
2016-02-15 21:09:34 +08:00
|
|
|
removePlugin(pluginPath, p.Id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|