Skip to content

Commit

Permalink
Merge pull request #2 from Frama-C/feature/add-verbose
Browse files Browse the repository at this point in the history
add -v (verbose) option, unset by default
  • Loading branch information
vprevosto authored Dec 8, 2022
2 parents cf3890f + 2911efc commit e9f5e89
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion headache.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
name: "headache"
version: "1.05"
version: "1.06"

license: "GNU Library General Public License"

Expand Down
19 changes: 14 additions & 5 deletions headache_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ open Config_builtin
open Headache


(***************************************************************************)
(** {2 Command-line options} *)

let verbose = ref false

(***************************************************************************)
(** {2 Configuration files} *)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -234,6 +239,10 @@ let main () =
Arg.Unit (fun () -> action := Extract),
" Extract headers from files";

"-v",
Arg.Set verbose,
" Enable verbose output";

]

anonymous
Expand Down
2 changes: 1 addition & 1 deletion info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
(**************************************************************************)

let name = "headache"
let version = "1.05"
let version = "1.06"
7 changes: 4 additions & 3 deletions skip.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand Down

0 comments on commit e9f5e89

Please sign in to comment.