Commits

camlspotter committed 16b5bba

write spot files

  • Participants
  • Parent commits 0bc33fa
  • Branches dev

Comments (0)

Files changed (3)

       (Format.list "" pp_print_string)
       file.Unit.loadpath
 
+  let write_spot path =
+    let file = load (Cmt.of_path path) in
+    let spot = match Filename.split_extension path with
+      | body, (".cmi" | ".mli" | ".cmti") -> body ^ ".spit"
+      | body, _ -> body ^ ".spot"
+    in
+    Spot.File.save spot (Spot.Unit.to_file file)
+
   let query_by_kind_path file kind path = 
     try Some (File.find_path_in_flat file (kind, path)) with Not_found -> None
   ;;
     match C.mode with
     | `Dump path                   -> ignore (load path)
     | `Info path                   -> info path
+    | `Spot path                   -> write_spot path
     | `Query (path, spec)          -> query path spec
 (*
     | `Typecheck args              -> typecheck args
 \tUse query:\n\
 \t\tocamlspot use <search> <targets>\n\
 \n\
+\tWrite spot/spit file:\n\
+\t\tocamlspot spot <file>\n\
+\n\
 \tType check and spot creation:\n\
 \t\tocamlspot typecheck <args>\n\
 \n\
     match anonargs with
     | [ "query"; spec ]        -> `Query (SearchSpec.parse spec)
     | [ "info"; file ]         -> `Info file
+    | [ "spot"; file ]         -> `Spot file
     | "use" :: spec :: targets -> `Use (SearchSpec.parse spec, targets)
     | "typecheck" :: rest      -> `Typecheck rest
     | "recheck" :: rest        -> `Recheck rest

spotconfig_intf.ml

   
   val mode : [ `Dump      of string
              | `Info      of string
+             | `Spot      of string
              | `Query     of string * SearchSpec.t
              | `Use       of (string * SearchSpec.t) * string list
              | `Recheck   of string list