Skip to content

Commit

Permalink
Merge pull request #18 from asenci/asenci/stdout-output
Browse files Browse the repository at this point in the history
Support stdout output
  • Loading branch information
pteich authored Oct 19, 2023
2 parents 3768787 + 5b4203d commit d0fbcae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ func Run(ctx context.Context, conf *flags.Flags) {
conf.Fields = strings.Split(conf.Fieldlist, ",")
}

outfile, err := os.Create(conf.Outfile)
if err != nil {
log.Fatalf("Error creating output file - %s", err)
var outfile *os.File

if conf.Outfile == "-" {
outfile = os.Stdout
} else {
outfile, err = os.Create(conf.Outfile)
if err != nil {
log.Fatalf("Error creating output file - %s", err)
}
defer outfile.Close()
}
defer outfile.Close()

var rangeQuery *elastic.RangeQuery

Expand Down

0 comments on commit d0fbcae

Please sign in to comment.