mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -1,7 +1,6 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
@@ -23,7 +22,7 @@ func runDbCommand(command func(commandLine utils.CommandLine, sqlStore *sqlstore
|
|||||||
cfg.Load(&setting.CommandLineArgs{
|
cfg.Load(&setting.CommandLineArgs{
|
||||||
Config: cmd.String("config"),
|
Config: cmd.String("config"),
|
||||||
HomePath: cmd.String("homepath"),
|
HomePath: cmd.String("homepath"),
|
||||||
Args: flag.Args(),
|
Args: context.Args(),
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.LogConfigSources()
|
cfg.LogConfigSources()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -18,13 +17,13 @@ var version = "master"
|
|||||||
func main() {
|
func main() {
|
||||||
setupLogging()
|
setupLogging()
|
||||||
|
|
||||||
flag.Parse()
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "Grafana cli"
|
app.Name = "Grafana cli"
|
||||||
app.Usage = ""
|
app.Usage = ""
|
||||||
app.Author = "Grafana Project"
|
app.Author = "Grafana Project"
|
||||||
app.Email = "https://github.com/grafana/grafana"
|
app.Email = "https://github.com/grafana/grafana"
|
||||||
app.Version = version
|
app.Version = version
|
||||||
|
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "pluginsDir",
|
Name: "pluginsDir",
|
||||||
|
|||||||
Reference in New Issue
Block a user