dbuenzli/cmdliner

Formatting issue with man page block

michaelRichards99 opened this issue · 2 comments

Following this tutorial, and modifying the man page block to use indented paragraphs and noblanks results in incorrect indentation when the --help format is plain.

Here is the entire main.ml program that causes the issue.

open Cmdliner
let chorus count msg = for i = 1 to count do print_endline msg done
let count =
  let doc = "Repeat the message $(docv) times." in
  Arg.(value & opt int 10 & info ["c"; "count"] ~docv:"COUNT" ~doc)

let msg =
let env =
  let doc = "Overrides the default message to print." in
  Cmd.Env.info "CHORUS_MSG" ~doc
in
let doc = "The message to print." in
Arg.(value & pos 0 string "Revolt!" & info [] ~env ~docv:"MSG" ~doc)

let chorus_t = Term.(const chorus $ count $ msg)

let cmd =
  let doc = "print a customizable message repeatedly" in
  let man = 
    [
      `S "DESCRIPTION";
      `P
        "description of the application.";
      `P "notice:";
      `Noblank;
      `I
        ( "label 1",
          "text 1" );
      `Noblank;
      `I
        ( "label 2",
          "text 2" );
      `Noblank;
      `I 
        ( "label 3",
          "text 3" );
      `Noblank;
      `I
        ( "label 4",
          "text 4" );
    ]
  in
  let info = Cmd.info "chorus" ~version:"%‌%VERSION%%" ~doc ~man in
  Cmd.v info chorus_t
let main () = exit (Cmd.eval cmd)
let () = main ()

The output looks correct on all other formats.
The resulting incorrect output when --help=plain is added is:

DESCRIPTION
       description of the application.

       notice:
       label 1
           text 1       label 2
                            text 2       label 3
                                             text 3       label 4
                                                              text 4

I think this is @reynir's fix #175

Yes, in #175 I attempt to fix this issue.