let parse_input ?default_arch ?(extras=[]) (urilist : string list list) =
  let default = match List.flatten urilist with
    |uri::_ -> let (p,_,_) = Input.parse_uri uri in Some p
    |-> None
  in
  let filelist =
    List.map (fun uris ->
      List.filter_map (fun uri ->
        let (t,_,_) as p = Input.parse_uri uri in
        if Some t = default then Some p else None
      ) uris
    ) urilist
  in
  match default, filelist with
  |None,_ -> fatal "No input specified"
  |Some Url.Cudf,[[p]] when (unpack p) = "-" -> fatal "no stdin for cudf yet"
  |Some Url.Cudf,[[p]] -> cudf_load_list (unpack p)
  |Some Url.Cudf, l when (List.flatten l) = [] -> fatal "how do you know it's a cudf ?"
  |Some Url.Cudf, l -> 
      if List.length (List.flatten l) > 1 then
        warning "more then one cudf speficied on the command line";
      let p = List.hd (List.flatten l) in 
      cudf_load_list (unpack p)

  |Some Url.Deb,ll ->
      let dll = 
        List.map (fun l ->
          let filelist = List.map unpack l in
          Debian.Packages.input_raw ?default_arch filelist
        ) ll 
      in
      deb_load_list ~extras dll

  |Some Url.Eclipse, ll ->
      let dll = 
        List.map (fun l ->
          let filelist = List.map unpack l in
          Eclipse.Packages.input_raw filelist
        ) ll 
      in
      eclipse_load_list ~extras dll

  |Some Url.Hdlist, ll -> 
IFDEF HASRPM THEN
      let dll = 
        List.map (fun l ->
          let filelist = List.map unpack l in
          Rpm.Packages.Hdlists.input_raw filelist
        ) ll 
      in
      rpm_load_list dll
ELSE
    fatal "hdlist Not supported. re-configure with --with-rpm"
END

  |Some Url.Synthesis, ll -> 
IFDEF HASRPM THEN
      let dll = 
        List.map (fun l ->
          let filelist = List.map unpack l in
          Rpm.Packages.Synthesis.input_raw filelist
        ) ll 
      in
      rpm_load_list dll
ELSE
    fatal "synthesis input format not supported. re-configure with --with-rpm"
END
(*
  |Some (Url.Pgsql|Url.Sqlite), [((Url.Pgsql|Url.Sqlite) as dbtype,info,(Some query))] ->
IFDEF HASDB THEN
      let db = Db.Backend.init_database dbtype info (Idbr.parse_query query) in
      let l = Db.Backend.load_selection db (`All) in
      deb_load_list ~extras [l]
ELSE
    fatal "%s Not supported. re-configure with --with-??" (Url.scheme_to_string dbtype)
END
*)

    |Some s,_ -> fatal "%s Not supported" (Url.scheme_to_string s)