Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion action.mli
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,16 @@ val io_null : unit IO.output
val file_lines_exn : string -> string list
val file_lines : string -> string list

(** read lines from file skipping empty lines and comments (lines starting with '#') *)
(** Read lines from file skipping empty lines and comments (lines starting with '#').

Moreover, comments are stripped from lines (all characters
including and following a '#') and returned lines are trimmed. *)
val make_config_lines : string list -> string list
val config_lines_exn : string -> string list

(** [config_lines file] read [file] and return the config lines.

See {!make_config_lines} for details on config lines. *)
val config_lines : string -> string list


Expand Down
22 changes: 22 additions & 0 deletions test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,28 @@ let () = test "Web.urlencode" @@ fun () ->
assert_equal (Web.urlencode "Hello Günter") "Hello+G%C3%BCnter";
()

let () = test "Action.make_config_lines" @@ fun () ->
let config_lines = [
"";
"foobar";
"# only comment line";
"arg # a comment";
"test # comment1 # comment2 ";
" test # comment ";
"foo";
" baz";
"bar ";
] in
assert_equal ~printer:(Stre.list (Printf.sprintf "%S")) (Action.make_config_lines config_lines) [
"foobar";
"arg";
"test";
"test";
"foo";
"baz";
"bar"
]

let () =
let open Lwt.Syntax in
let rec pings f = function
Expand Down
Loading