Skip to content

Commit e7d83d6

Browse files
committed
plotgitsch: allow to specify a filename
1 parent d066c11 commit e7d83d6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

plotkicadsch/src/plotgitsch.ml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ module ImageDiff = struct
297297
List.map ~f:(SysAbst.finalize_tmp_file ~keep_as:None) [from_filename; to_filename] >|= fun _ -> ret
298298
end
299299

300-
let doit from_fs to_fs differ textdiff libs keep colors =
300+
let doit from_fs to_fs file_to_diff differ textdiff libs keep colors =
301+
301302
let module_d = match differ with
302303
| Image_Diff -> (module ImageDiff: Differ)
303304
| Internal s -> internal_diff s colors in
@@ -306,10 +307,15 @@ let doit from_fs to_fs differ textdiff libs keep colors =
306307
let module T = (val to_fs: Simple_FS) in
307308
let module FromP = FSPainter (D.S) (F) in
308309
let module ToP = FSPainter (D.S) (T) in
309-
let from_list = FromP.find_schematics () in
310-
let to_list = ToP.find_schematics () in
311-
let file_list = intersect_lists from_list to_list in
312-
310+
let file_list =
311+
match file_to_diff with
312+
| None -> let from_list = FromP.find_schematics () in
313+
let to_list = ToP.find_schematics () in
314+
intersect_lists from_list to_list
315+
| Some filename ->
316+
let filename_l = String.split ~on:'/' filename in
317+
Lwt.return filename_l
318+
in
313319
let preload_libs () =
314320
Lwt_list.fold_left_s (fun c f -> Lwt_stream.fold D.S.add_lib (Lwt_io.lines_of_file f) c) (D.S.initial_context () ) libs in
315321

@@ -379,6 +385,11 @@ let differ =
379385
let docv = "diff strategy used" in
380386
Arg.(conv ~docv ((fun d -> Result.Ok(Internal d)), pp_differ))
381387

388+
let diff_of_file =
389+
let doc = "diff only selected file $(docv)." in
390+
let docv = "FILENAME" in
391+
Arg.(value & opt (some file) None & info ["f"; "file"] ~doc ~docv)
392+
382393
let internal_diff =
383394
let doc = "use an internal diff algorithm and use the $(docv) to display the result." in
384395
let docv = "BROWSER" in
@@ -428,7 +439,7 @@ let colors =
428439
let docv = "old:new:foreground:background" in
429440
Arg.(value & opt get_colors None & info ["c"; "colors"] ~doc ~docv)
430441

431-
let plotgitsch_t = Term.(const doit $ from_ref $ to_ref $ internal_diff $ textual_diff $ preloaded_libs $ keep_files $ colors)
442+
let plotgitsch_t = Term.(const doit $ from_ref $ to_ref $ diff_of_file $ internal_diff $ textual_diff $ preloaded_libs $ keep_files $ colors)
432443

433444

434445
let info =

0 commit comments

Comments
 (0)