mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 00:37:04 -06:00
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
|
|
"github.com/codegangsta/cli"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
|
)
|
|
|
|
var version = "master"
|
|
|
|
func main() {
|
|
setupLogging()
|
|
|
|
services.Init(version)
|
|
|
|
app := cli.NewApp()
|
|
app.Name = "Grafana cli"
|
|
app.Usage = ""
|
|
app.Author = "Grafana Project"
|
|
app.Email = "https://github.com/grafana/grafana"
|
|
app.Version = version
|
|
app.Flags = []cli.Flag{
|
|
cli.StringFlag{
|
|
Name: "pluginsDir",
|
|
Usage: "path to the grafana plugin directory",
|
|
Value: utils.GetGrafanaPluginDir(runtime.GOOS),
|
|
EnvVar: "GF_PLUGIN_DIR",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "repo",
|
|
Usage: "url to the plugin repository",
|
|
Value: "https://grafana.net/api/plugins",
|
|
EnvVar: "GF_PLUGIN_REPO",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "debug, d",
|
|
Usage: "enable debug logging",
|
|
},
|
|
}
|
|
|
|
app.Commands = commands.Commands
|
|
app.CommandNotFound = cmdNotFound
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
logger.Errorf("%v", err)
|
|
}
|
|
}
|
|
|
|
func setupLogging() {
|
|
for _, f := range os.Args {
|
|
if f == "-D" || f == "--debug" || f == "-debug" {
|
|
logger.SetDebug(true)
|
|
}
|
|
}
|
|
}
|
|
|
|
func cmdNotFound(c *cli.Context, command string) {
|
|
fmt.Printf(
|
|
"%s: '%s' is not a %s command. See '%s --help'.\n",
|
|
c.App.Name,
|
|
command,
|
|
c.App.Name,
|
|
os.Args[0],
|
|
)
|
|
os.Exit(1)
|
|
}
|