grafana/pkg/cmd/grafana-cli/commands/remove_command.go

30 lines
531 B
Go
Raw Normal View History

2016-02-15 21:09:34 +08:00
package commands
import (
"context"
2016-02-15 21:09:34 +08:00
"errors"
2016-04-19 14:32:23 +08:00
"fmt"
"strings"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
2016-02-15 21:09:34 +08:00
)
func removeCommand(c utils.CommandLine) error {
pluginID := c.Args().First()
if pluginID == "" {
return errors.New("missing plugin parameter")
2016-02-15 21:09:34 +08:00
}
err := uninstallPlugin(context.Background(), pluginID, c)
if err != nil {
if strings.Contains(err.Error(), "no such file or directory") {
return fmt.Errorf("plugin does not exist")
2016-02-15 21:09:34 +08:00
}
return err
} else {
logRestartNotice()
2016-02-15 21:09:34 +08:00
}
return nil
2016-02-15 21:09:34 +08:00
}