File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,9 +185,16 @@ val io_null : unit IO.output
185185val file_lines_exn : string -> string list
186186val file_lines : string -> string list
187187
188- (* * read lines from file skipping empty lines and comments (lines starting with '#') *)
188+ (* * Read lines from file skipping empty lines and comments (lines starting with '#').
189+
190+ Moreover, comments are stripped from lines (all characters
191+ including and following a '#') and returned lines are trimmed. *)
189192val make_config_lines : string list -> string list
190193val config_lines_exn : string -> string list
194+
195+ (* * [config_lines file] read [file] and return the config lines.
196+
197+ See {!make_config_lines} for details on config lines. *)
191198val config_lines : string -> string list
192199
193200
Original file line number Diff line number Diff line change @@ -544,6 +544,28 @@ let () = test "Web.urlencode" @@ fun () ->
544544 assert_equal (Web. urlencode " Hello Günter" ) " Hello+G%C3%BCnter" ;
545545 ()
546546
547+ let () = test " Action.make_config_lines" @@ fun () ->
548+ let config_lines = [
549+ " " ;
550+ " foobar" ;
551+ " # only comment line" ;
552+ " arg # a comment" ;
553+ " test # comment1 # comment2 " ;
554+ " test # comment " ;
555+ " foo" ;
556+ " baz" ;
557+ " bar " ;
558+ ] in
559+ assert_equal ~printer: (Stre. list (Printf. sprintf " %S" )) (Action. make_config_lines config_lines) [
560+ " foobar" ;
561+ " arg" ;
562+ " test" ;
563+ " test" ;
564+ " foo" ;
565+ " baz" ;
566+ " bar"
567+ ]
568+
547569let () =
548570 let open Lwt.Syntax in
549571 let rec pings f = function
You can’t perform that action at this time.
0 commit comments