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 9aa575655228ef1c352ee27109bb9dd52dd2181f
parent 8e1b2624184879b60172fdd5e1f0eb462771b122
Author: Jean Schurger <jean@schurger.org>
Date:   Fri, 13 Nov 2026 23:34:21 -0500

divelog-cli: table (logbook as a markdown table) and sites

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 | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/Packages/DiveKit/Sources/divelog-cli/main.swift b/Packages/DiveKit/Sources/divelog-cli/main.swift @@ -74,6 +74,33 @@ do { let check = try LogRepository(directory: directory.appendingPathComponent("relecture"), branch: account, authorName: "Sub Rascasse", authorEmail: account) _ = try await check.sync(transport: transport) describe(try await check.logbook()) + case "table": + // Tout le carnet en tableau markdown, de la plus ancienne à la plus récente. + let log = try await repository.logbook() + func cell(_ text: String) -> String { text.replacingOccurrences(of: "|", with: "/").replacingOccurrences(of: "\n", with: " ") } + print("| N° | Date | Heure | Lieu | Prof. | Durée | Eau | Binôme | Guide | Source |") + print("|---|---|---|---|---|---|---|---|---|---|") + for dive in log.dives.reversed() { + let c = NaiveTime.components(dive.when) + let date = String(format: "%04d-%02d-%02d", c.year ?? 0, c.month ?? 0, c.day ?? 0) + let time = String(format: "%02d:%02d", c.hour ?? 0, c.minute ?? 0) + let guessed = dive.notes.contains("Heure non écrite") + var source = dive.computerModel ?? "saisie" + if let range = dive.notes.range(of: "Carnet papier [0-9]+, page [0-9]+( \\(écrit n° [0-9]+\\))?", options: .regularExpression) { + source = String(dive.notes[range]).replacingOccurrences(of: "Carnet papier ", with: "carnet ").replacingOccurrences(of: ", page ", with: " p. ") + } + let temp = dive.waterTemperature.map { String(format: "%.0f °C", $0) } ?? "" + print("| \(dive.number) | \(date) | \(time)\(guessed ? " ?" : "") | \(cell(log.site(of: dive)?.name ?? "")) | \(String(format: "%.1f", dive.maxDepth)) m | \(dive.durationSeconds / 60) min | \(temp) | \(cell(dive.buddy)) | \(cell(dive.divemaster)) | \(cell(source)) |") + } + case "sites": + let log = try await repository.logbook() + var counts = [UInt32: Int]() + for dive in log.dives { if let uuid = dive.siteUUID { counts[uuid, default: 0] += 1 } } + print("| Lieu | Plongées | Latitude | Longitude |") + print("|---|---|---|---|") + for site in log.sites.values.sorted(by: { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }) { + print("| \(site.name) | \(counts[site.uuid] ?? 0) | \(site.latitude.map { String(format: "%.5f", $0) } ?? "") | \(site.longitude.map { String(format: "%.5f", $0) } ?? "") |") + } case "apply": // Applique une liste de modifications (tableau JSON de LogChange) et l'envoie. guard let path = arguments.dropFirst().first else { fail("fichier de modifications manquant") }