grafana/pkg/cmd/grafana-cli/commands/listversions_command.go
Arve Knudsen eb98d9c15b
grafana-cli: Upgrade to urfave/cli v2 (#22402)
* grafana-cli: Upgrade to urfave/cli v2
2020-02-26 12:27:31 +01:00

37 lines
696 B
Go

package commands
import (
"errors"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
)
func validateVersionInput(c utils.CommandLine) error {
arg := c.Args().First()
if arg == "" {
return errors.New("please specify plugin to list versions for")
}
return nil
}
func (cmd Command) listVersionsCommand(c utils.CommandLine) error {
if err := validateVersionInput(c); err != nil {
return err
}
pluginToList := c.Args().First()
plugin, err := cmd.Client.GetPlugin(pluginToList, c.String("repo"))
if err != nil {
return err
}
for _, i := range plugin.Versions {
logger.Infof("%v\n", i.Version)
}
return nil
}