Skip to content

Commit

Permalink
Support stdout output
Browse files Browse the repository at this point in the history
  • Loading branch information
asenci committed Aug 26, 2022
1 parent cd4c36c commit 5b4203d
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 @@ -61,11 +61,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 5b4203d

Please sign in to comment.