From cd270dc477dccafbfa64942e5d8d29ba7839c85c Mon Sep 17 00:00:00 2001 From: Xiang Dai <764524258@qq.com> Date: Thu, 17 Jan 2019 19:23:38 +0800 Subject: [PATCH] logcli: remove default url (#194) Signed-off-by: Xiang Dai <764524258@qq.com> --- cmd/logcli/main.go | 7 ++++++- docs/logcli.md | 6 ++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index be6023ebdb7e..28d65eeaf68c 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" kingpin "gopkg.in/alecthomas/kingpin.v2" @@ -8,7 +9,7 @@ import ( var ( app = kingpin.New("logcli", "A command-line for loki.") - addr = app.Flag("addr", "Server address.").Default("https://log-us.grafana.net").Envar("GRAFANA_ADDR").String() + addr = app.Flag("addr", "Server address.").Default("").Envar("GRAFANA_ADDR").String() username = app.Flag("username", "Username for HTTP basic auth.").Default("").Envar("GRAFANA_USERNAME").String() password = app.Flag("password", "Password for HTTP basic auth.").Default("").Envar("GRAFANA_PASSWORD").String() @@ -27,6 +28,10 @@ var ( func main() { switch kingpin.MustParse(app.Parse(os.Args[1:])) { case queryCmd.FullCommand(): + if *addr == "" { + fmt.Println("Server address cannot be empty") + os.Exit(1) + } doQuery() case labelsCmd.FullCommand(): doLabels() diff --git a/docs/logcli.md b/docs/logcli.md index 7d27ed81007e..d122e9c2d0ea 100644 --- a/docs/logcli.md +++ b/docs/logcli.md @@ -31,8 +31,7 @@ A command-line for loki. Flags: --help Show context-sensitive help (also try --help-long and --help-man). - --addr="https://log-us.grafana.net" - Server address. + --addr="" Server address, need to specify. --username="" Username for HTTP basic auth. --password="" Password for HTTP basic auth. @@ -53,8 +52,7 @@ Run a LogQL query. Flags: --help Show context-sensitive help (also try --help-long and --help-man). - --addr="https://log-us.grafana.net" - Server address. + --addr="" Server address, need to specify. --username="" Username for HTTP basic auth. --password="" Password for HTTP basic auth. --limit=30 Limit on number of entries to print.