let main () =
  Arg.parse options
    (fun s -> remaining := s :: !remaining)
    (Printf.sprintf "Usage: %s [options] <files>\nThe '-' file is the standard input.\nOptions are:" Sys.argv.(0));

  try
    let rss =
      match List.rev !remaining with
        [] ->
          prerr_endline (Printf.sprintf "Usage: %s [options] <files>" Sys.argv.(0));
          exit 1
      | [f] -> rss_of_file f
      | f :: q ->
          List.fold_left
            (fun acc f -> Rss.merge_channels (rss_of_file f) acc)
            (rss_of_file f)
            q
    in
    match !output_type with
      Rss ->
        Rss.print_channel (formatter_of_out_channel stdout) rss
  with
    Sys_error s
  | Failure s ->
      prerr_endline s ; exit 1