Fix output format not being respected for STDOUT
This commit is contained in:
parent
69a513d814
commit
29d2796692
1 changed files with 9 additions and 8 deletions
|
|
@ -315,6 +315,7 @@ func (h *Handler) OnInitialize() (ans string, err error) {
|
|||
err = h.graphics_handler.Initialize(h.lp)
|
||||
h.result_manager.set_root_dir()
|
||||
h.draw_screen()
|
||||
h.lp.SendOverlayReady()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -772,16 +773,16 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
|
|||
return
|
||||
}
|
||||
m := strings.Join(selections, "\n")
|
||||
if opts.OutputFormat == "json" {
|
||||
payload["paths"] = selections
|
||||
if current_filter != "" {
|
||||
payload["current_filter"] = current_filter
|
||||
}
|
||||
b, _ := json.MarshalIndent(payload, "", " ")
|
||||
m = string(b)
|
||||
}
|
||||
fmt.Print(m)
|
||||
if opts.WriteOutputTo != "" {
|
||||
if opts.OutputFormat == "json" {
|
||||
payload["paths"] = selections
|
||||
if current_filter != "" {
|
||||
payload["current_filter"] = current_filter
|
||||
}
|
||||
b, _ := json.MarshalIndent(payload, "", " ")
|
||||
m = string(b)
|
||||
}
|
||||
os.WriteFile(opts.WriteOutputTo, []byte(m), 0600)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue