<commit_before>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/log"
)

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 {
		log.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/default.ini exists, grafana is not installed as package
	_, err := os.Stat("../conf/default.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{<commit_msg>Revert "feat(cli): detects plugin folder for dev env"<commit_after>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/log"
	"strings"
)

var version = "master"

func getGrafanaPluginDir() string {
	currentOS := runtime.GOOS
	defaultNix := "/var/lib/grafana/plugins"

	if currentOS == "windows" {
		return "C:\\opt\\grafana\\plugins"
	}

	pwd, err := os.Getwd()

	if err != nil {
		log.Error("Could not get current path. using default")
		return defaultNix
	}

	if isDevenvironment(pwd) {
		return "../../../data/plugins"
	}

	return defaultNix
}

func isDevenvironment(pwd string) bool {
	// if grafana-cli is executed from the cmd folder we can assume
	// that its in development environment.
	return strings.HasSuffix(pwd, "/pkg/cmd/grafana-cli")
}

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{
{'fraction_non_alphanumeric': 0.15178571428571427, 'fraction_numerical': 0.0, 'mean_word_length': 3.5250403877221324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7528721', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1078, 'n_words': 230}