Fix output format not being respected for STDOUT

This commit is contained in:
Kovid Goyal 2025-11-23 11:02:33 +05:30
parent 69a513d814
commit 29d2796692
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -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)
}
}