Skip to content

Commit

Permalink
logcli: remove default url (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Dai <764524258@qq.com>
  • Loading branch information
daixiang0 authored and tomwilkie committed Jan 17, 2019
1 parent e3e4a2d commit cd270dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cmd/logcli/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package main

import (
"fmt"
"os"

kingpin "gopkg.in/alecthomas/kingpin.v2"
)

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()

Expand All @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions docs/logcli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit cd270dc

Please sign in to comment.