39 Star 144 Fork 3

Gitee 极速下载 / grafana

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/grafana/grafana
克隆/下载
main.go 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
bergquist 提交于 2016-06-03 13:40 . fix(cli): fixes broken import
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"
)
var version = "master"
func getGrafanaPluginDir() string {
currentOS := runtime.GOOS
defaultNix := "/var/lib/grafana/plugins"
if currentOS == "windows" {
return "../data/plugins"
}
pwd, err := os.Getwd()
if err != nil {
logger.Error("Could not get current path. using default")
return defaultNix
}
if isDevenvironment(pwd) {
return "../data/plugins"
}
return defaultNix
}
func isDevenvironment(pwd string) bool {
// if ../conf/defaults.ini exists, grafana is not installed as package
// that its in development environment.
_, err := os.Stat("../conf/defaults.ini")
return err == nil
}
func main() {
setupLogging()
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: getGrafanaPluginDir(),
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)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/grafana.git
git@gitee.com:mirrors/grafana.git
mirrors
grafana
grafana
v3.1.1

搜索帮助

344bd9b3 5694891 D2dac590 5694891