11open Lib
22
3- let extract ~duplicatesAllowed ~paths =
3+ let extract ~duplicatesAllowed ~verbose ~ paths =
44 try
5- let messages = Extractor. extract ~duplicates Allowed paths in
5+ let messages = Extractor. extract ~duplicates Allowed ~verbose paths in
66 let json = `List (messages |> List. map Message. toJson) in
77 json |> Yojson.Basic. pretty_to_channel stdout;
88 print_newline ()
@@ -25,19 +25,31 @@ type options = {
2525 mutable showVersion : bool ;
2626 mutable paths : string list ;
2727 mutable duplicatesAllowed : bool ;
28+ mutable verbose : bool ;
2829}
2930
3031let run () =
31- let options = {showVersion = false ; paths = [] ; duplicatesAllowed = false } in
32+ let options =
33+ {
34+ showVersion = false ;
35+ paths = [] ;
36+ duplicatesAllowed = false ;
37+ verbose = false ;
38+ }
39+ in
3240 let processInputFilename filename =
3341 options.paths < - filename :: options.paths
3442 in
3543 let allowDuplicates () = options.duplicatesAllowed < - true in
3644 let showVersion () = options.showVersion < - true in
45+ let verbose () = options.verbose < - true in
3746
3847 let args =
3948 [
4049 (" -v" , Arg. Unit showVersion, " shows the program version" );
50+ ( " --verbose" ,
51+ Arg. Unit verbose,
52+ " log some information like the current processed file path" );
4153 ( " --allow-duplicates" ,
4254 Arg. Unit allowDuplicates,
4355 " allows messages with identical `id` props if `defaultMessage` props \
@@ -51,6 +63,7 @@ let run () =
5163 match options with
5264 | {showVersion = true } -> print_endline Version. version
5365 | {paths = [] } -> Arg. usage args usage
54- | {paths; duplicatesAllowed} -> extract ~duplicates Allowed ~paths
66+ | {paths; duplicatesAllowed; verbose} ->
67+ extract ~duplicates Allowed ~verbose ~paths
5568
5669let () = run ()
0 commit comments