Commit 7d68d6ed by gotjosh Committed by GitHub

grafana-cli: Fix receiving flags via command line (#17617)

`grafana-cli` uses the third-party library to define the flags and not
the standard library. Using `flag.Parse` conflicts with the defined
flags from our third-party library.

In the case where `flag.Parse` is used, the CLI assumes that definitions
provided are not needed and will not define them; producing errors of
the kind `flag provided but not defined --example-flag`.

Using the context to read any arguments (including flags) is the
recommended approach by the third-party library.
parent 3424b642
package commands
import (
"flag"
"os"
"github.com/codegangsta/cli"
......@@ -23,7 +22,7 @@ func runDbCommand(command func(commandLine utils.CommandLine, sqlStore *sqlstore
cfg.Load(&setting.CommandLineArgs{
Config: cmd.String("config"),
HomePath: cmd.String("homepath"),
Args: flag.Args(),
Args: context.Args(),
})
cfg.LogConfigSources()
......
package main
import (
"flag"
"fmt"
"os"
"runtime"
......@@ -18,13 +17,13 @@ var version = "master"
func main() {
setupLogging()
flag.Parse()
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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment