diff --git a/headache.opam b/headache.opam index 8f20ace..413513b 100644 --- a/headache.opam +++ b/headache.opam @@ -1,6 +1,6 @@ opam-version: "2.0" name: "headache" -version: "1.05" +version: "1.06" license: "GNU Library General Public License" diff --git a/headache_tool.ml b/headache_tool.ml index 90e4a27..2544245 100644 --- a/headache_tool.ml +++ b/headache_tool.ml @@ -18,6 +18,11 @@ open Config_builtin open Headache +(***************************************************************************) +(** {2 Command-line options} *) + +let verbose = ref false + (***************************************************************************) (** {2 Configuration files} *) @@ -162,9 +167,9 @@ let create_header header header_width filename = let generator = find_generator filename in let skip_lst = find_skips filename in pipe_file (fun ic oc -> - let () = Skip.skip skip_lst ic (Some oc) in + let () = Skip.skip ~verbose:!verbose skip_lst ic (Some oc) in let line = generator.Model.remove ic in - let () = Skip.skip skip_lst ic (Some oc) in + let () = Skip.skip ~verbose:!verbose skip_lst ic (Some oc) in generator.Model.create oc header header_width; output_string oc line; copy ic oc @@ -176,9 +181,9 @@ let remove_header filename = let generator = find_generator filename in let skip_lst = find_skips filename in pipe_file (fun ic oc -> - let () = Skip.skip skip_lst ic (Some oc) in + let () = Skip.skip ~verbose:!verbose skip_lst ic (Some oc) in let line = generator.Model.remove ic in - let () = Skip.skip skip_lst ic (Some oc) in + let () = Skip.skip ~verbose:!verbose skip_lst ic (Some oc) in output_string oc line; copy ic oc ) filename @@ -188,7 +193,7 @@ let extract_header filename = let generator = find_generator filename in let skip_lst = find_skips filename in rd_pipe_file (fun ic -> - let () = Skip.skip skip_lst ic None in + let () = Skip.skip ~verbose:!verbose skip_lst ic None in generator.Model.extract ic ) filename @@ -234,6 +239,10 @@ let main () = Arg.Unit (fun () -> action := Extract), " Extract headers from files"; + "-v", + Arg.Set verbose, + " Enable verbose output"; + ] anonymous diff --git a/info.ml b/info.ml index e98689a..d124383 100644 --- a/info.ml +++ b/info.ml @@ -14,4 +14,4 @@ (**************************************************************************) let name = "headache" -let version = "1.05" +let version = "1.06" diff --git a/skip.ml b/skip.ml index c55e491..76ba9ff 100644 --- a/skip.ml +++ b/skip.ml @@ -24,7 +24,7 @@ type param_skip = bool * regexp_skip ;; -let skip skip_lst ic oc = +let skip ~verbose skip_lst ic oc = let multiple_skip_lst,simple_skip_lst = List.partition (fun (_,(multiple,_)) -> multiple) skip_lst in @@ -50,8 +50,9 @@ let skip skip_lst ic oc = with Not_found -> match_line simple_skip_lst; in - prerr_endline - ("Line : "^line^" skipped"); + if verbose then + prerr_endline + ("Line : "^line^" skipped"); (match oc with | None -> () | Some oc ->