commands.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package commands
  2. import (
  3. "github.com/codegangsta/cli"
  4. "github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
  5. )
  6. func runCommand(command func(commandLine CommandLine) error) func(context *cli.Context) {
  7. return func(context *cli.Context) {
  8. cmd := &contextCommandLine{context}
  9. if err := command(cmd); err != nil {
  10. log.Errorf("%v\n\n", err)
  11. cmd.ShowHelp()
  12. } else {
  13. log.Info("Restart grafana after installing plugins . <service grafana-server restart>\n")
  14. }
  15. }
  16. }
  17. var Commands = []cli.Command{
  18. {
  19. Name: "install",
  20. Usage: "installs stuff",
  21. Action: runCommand(installCommand),
  22. }, {
  23. Name: "list-remote",
  24. Usage: "list remote available plugins",
  25. Action: runCommand(listremoteCommand),
  26. }, {
  27. Name: "upgrade",
  28. Usage: "upgrades one plugin",
  29. Action: runCommand(upgradeCommand),
  30. }, {
  31. Name: "upgrade-all",
  32. Usage: "upgrades all your installed plugins",
  33. Action: runCommand(upgradeAllCommand),
  34. }, {
  35. Name: "ls",
  36. Usage: "list all installed plugins",
  37. Action: runCommand(lsCommand),
  38. }, {
  39. Name: "remove",
  40. Usage: "removes stuff",
  41. Action: runCommand(removeCommand),
  42. },
  43. }