commands.go 1.1 KB

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