Skip to content

Commit 6a2a4fe

Browse files
committed
in Bin_conf, discard *all* output from cmdliner
Currently, Cmdliner is given a formatter that drops any text, but Cmdliner can (and does) print whitespace via the non-overridden out_spaces, out_indent and out_newlines.
1 parent 3b8bf77 commit 6a2a4fe

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/bin_conf/Bin_conf.ml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,6 @@ let update_using_env conf =
520520
| [] -> conf
521521
| l -> failwith_user_errors ~from:"OCAMLFORMAT environment variable" l
522522

523-
let discard_formatter =
524-
Format.(
525-
formatter_of_out_functions
526-
{ (get_formatter_out_functions ()) with
527-
out_string= (fun _ _ _ -> ())
528-
; out_flush= (fun () -> ()) } )
529-
530523
let global_lib_term =
531524
Term.(
532525
const (fun conf_modif lib_conf ->
@@ -537,8 +530,9 @@ let global_lib_term =
537530

538531
let global_lib_term_eval =
539532
lazy
540-
(Cmd.eval_value ~err:discard_formatter ~help:discard_formatter
541-
(Cmd.v info global_lib_term) )
533+
(let discard = Format.make_formatter (fun _ _ _ -> ()) ignore in
534+
Cmd.eval_value ~err:discard ~help:discard (Cmd.v info global_lib_term)
535+
)
542536

543537
let update_using_cmdline config =
544538
match Lazy.force global_lib_term_eval with

0 commit comments

Comments
 (0)