- with Invalid_argument _ | End_of_file ->
- print_newline ();
- print_endline "TestLibrary report";
- print_endline "Succeeded URIs:";
- List.iter (fun s -> print_endline ("\t" ^ s)) (List.rev !ok);
- print_endline "Failed URIs:";
- List.iter (fun s -> print_endline ("\t" ^ s)) (List.rev !nok);
- print_newline ()
+ with exn ->
+ printf "Error trying to access '%s' (%s), skipping the file\n%!"
+ fname (Printexc.to_string exn)
+
+let _ =
+ let names = ref [] in
+ let tryvars = ref false in
+ let varsprefix = ref "" in
+ let usage = "testlibrary [OPTION] ... (uri1 | file1) (uri2 | file2) ..." in
+ let spec =
+ [ "-vars", Arg.Set tryvars, "try also variables" ;
+ "-novars", Arg.Clear tryvars, "do not try variables (default)" ;
+ "-varsprefix", Arg.Set_string varsprefix,
+ "limit variable choices to URIs beginning with prefix" ;
+ ]
+ in
+ Arg.parse spec (fun name -> names := name :: !names) usage;
+ let names = List.rev !names in
+ uri_predicate := BatchParser.uri_pred_of_conf !tryvars !varsprefix;
+ let status = (ref [], ref [], ref []) in (* <ok, nok, maybe> URIs *)
+ List.iter
+ (fun name ->
+ try
+ let uri = UriManager.uri_of_string name in
+ do_uri status uri
+ with UriManager.IllFormedUri _ ->
+ if Sys.file_exists name then
+ do_file status name
+ else
+ printf "Don't know what to do with '%s', ignoring it\n%!" name)
+ names