Skip to content

Commit

Permalink
Merge pull request #1 from rguilmont/better-cli
Browse files Browse the repository at this point in the history
Better cli
  • Loading branch information
rguilmont authored Jul 1, 2020
2 parents e848ef8 + e100710 commit 493f631
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ deploy:
- esl_darwin64
- esl_linux64
on:
repo: rguilmont/esl
tag: true
skip_cleanup: 'true'
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ For now, it is assumed that the logs comes from a Kubernetes cluster. I will mak
## Usage

```
Usage : ./test <context>
Usage : ./esl [flags...] <context>
-filter string
Overide filter in your context
Overide filter in your context
-from string
Start timestamp. (default "now-10m")
Start timestamp. (default "now-10m")
-to string
End timestamp. By default there's no end timestamp, it will infinitely loop.
End timestamp. By default there's no end timestamp, it will infinitely loop.
```
## Configuration

Expand Down
28 changes: 27 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import (

const esJSONPrefix = "_source."

// Export variables for version
var (
GitSummary string
GitCommit string
BuildDate string
)

func currentFilter(contextFilter string, cliFilter string) string {
if cliFilter != "" {
return cliFilter
Expand All @@ -30,14 +37,33 @@ func main() {
fmt.Println("esl, elasticsearch logs query utility.")
fmt.Println("By default, logs will be tailed, unless from and to flag are set.")

fmt.Printf("Usage : %v <context>\n", os.Args[0])
fmt.Printf("Usage : %v [flags...] <context>\n", os.Args[0])
flag.PrintDefaults()

}

version := flag.Bool("v", false, "Display version.")

from := flag.String("from", "now-10m", "Start timestamp.")
to := flag.String("to", "", "End timestamp. By default there's no end timestamp, it will infinitely loop.")
filter := flag.String("filter", "", "Overide filter in your context")
flag.Parse()

if *version {
fmt.Printf("Version: %v\n", GitSummary)
fmt.Printf("Commit hash: %v\n", GitCommit)
fmt.Printf("Build date: %v\n", BuildDate)
os.Exit(0)
}

if len(flag.Args()) != 1 {
fmt.Println("Invalid usage")

fmt.Printf("Usage : %v [flags...] <context>\n", os.Args[0])

flag.PrintDefaults()
os.Exit(1)
}
c := flag.Args()[0]

config, err := configuration.LoadConf(nil)
Expand Down

0 comments on commit 493f631

Please sign in to comment.