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.
This commit is contained in:
gotjosh
2019-06-18 10:25:37 +01:00
committed by GitHub
parent 3424b64299
commit 7d68d6ede2
2 changed files with 2 additions and 4 deletions

View File

@@ -1,7 +1,6 @@
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()