subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

commit 6d3b48b239663acba0bbadbb380ff76b7d728e02
parent 83afdc642a1e9cc5bd26e366db604a4a1804f4d6
Author: Jean Schurger <jean@schurger.org>
Date:   Sat, 14 Nov 2026 13:11:29 -0500

divelog-cli: renumber-plan lists dives whose number differs from their rank in time

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYG3yp7VDUZJzSBkvTc

Diffstat:
MPackages/DiveKit/Sources/divelog-cli/main.swift | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/Packages/DiveKit/Sources/divelog-cli/main.swift b/Packages/DiveKit/Sources/divelog-cli/main.swift @@ -42,6 +42,7 @@ guard let command = arguments.first, let email = environment["CLOUD_EMAIL"], let apply <changes.json> apply a JSON array of changes and push locate <site> <latitude> <longitude> set the position of a site merge <file> <from> <to> <number> merge several immersions of a file into one dive + renumber-plan JSON list of the dives whose number differs from their rank in time usage: divelog-cli inspect <file> show what a file contains (no network) """) } @@ -69,6 +70,17 @@ do { switch command { case "list": describe(try await repository.logbook()) + case "renumber-plan": + // Dives in chronological order should be numbered 1, 2, 3…: lists those that are not, with their notes, + // so that a list of changes can be prepared and reviewed before `apply`. + struct Entry: Encodable { let when: Int, number: Int, newNumber: Int, notes: String } + let ordered = try await repository.logbook().dives.sorted { $0.when < $1.when } + let entries = ordered.enumerated().compactMap { index, dive in + dive.number == index + 1 ? nil : Entry(when: dive.when, number: dive.number, newNumber: index + 1, notes: dive.notes) + } + let encoder = JSONEncoder() + encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes] + print(String(decoding: try encoder.encode(entries), as: UTF8.self)) case "import": guard let path = arguments.dropFirst().first else { fail("missing file to import") } let all = try DiveImporter.dives(from: Array(try Data(contentsOf: URL(fileURLWithPath: path))))