My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

day11: add snapshots command to list snapshots for a profile

Shows key, creation time, solution count, run count, and repo
commit SHAs for each snapshot, most recent first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+55
+54
day11/bin/cmd_snapshots.ml
··· 1 + (** snapshots command: list snapshots for a profile *) 2 + 3 + open Cmdliner 4 + 5 + let run profile_name profile_dir = 6 + match Common.load_profile ~profile_dir ~name:profile_name with 7 + | Error (`Msg e) -> Printf.eprintf "Error: %s\n%!" e; 1 8 + | Ok (_profile, paths) -> 9 + let snaps = Common.snapshot_dirs_by_recency paths in 10 + if snaps = [] then begin 11 + Printf.printf "No snapshots for profile '%s'\n%!" profile_name; 12 + 0 13 + end else begin 14 + Printf.printf "Snapshots for profile '%s' (%d):\n\n" profile_name 15 + (List.length snaps); 16 + List.iter (fun snap_dir -> 17 + let key = Fpath.basename snap_dir in 18 + let created = match Day11_batch.Snapshot.load snap_dir with 19 + | Ok s -> s.created 20 + | Error _ -> "?" 21 + in 22 + let n_solutions = 23 + let sol_dir = Day11_batch.Snapshot.solutions_dir snap_dir in 24 + match Bos.OS.Dir.contents sol_dir with 25 + | Ok files -> 26 + List.length (List.filter (fun p -> 27 + Fpath.has_ext ".json" p && Fpath.basename p <> "repos.json" 28 + ) files) 29 + | Error _ -> 0 30 + in 31 + let n_runs = 32 + let runs_dir = Day11_batch.Snapshot.runs_dir snap_dir in 33 + match Bos.OS.Dir.contents runs_dir with 34 + | Ok dirs -> List.length dirs 35 + | Error _ -> 0 36 + in 37 + let repos = match Day11_batch.Snapshot.load snap_dir with 38 + | Ok s -> 39 + String.concat ", " (List.map (fun (_, sha) -> 40 + String.sub sha 0 (min 12 (String.length sha)) 41 + ) s.repos) 42 + | Error _ -> "?" 43 + in 44 + Printf.printf " %s %s %d solutions, %d runs [%s]\n" 45 + key created n_solutions n_runs repos 46 + ) snaps; 47 + 0 48 + end 49 + 50 + let cmd = 51 + let doc = "List snapshots for a profile" in 52 + let info = Cmd.info "snapshots" ~doc in 53 + Cmd.v info 54 + Term.(const run $ Common.profile_term $ Common.profile_dir_term)
+1
day11/bin/main.ml
··· 17 17 Cmd_build.cmd; 18 18 Cmd_batch.cmd; 19 19 Cmd_diff.cmd; 20 + Cmd_snapshots.cmd; 20 21 Cmd_results.cmd; 21 22 Cmd_status.cmd; 22 23 Cmd_query.cmd;