From 697fd9551417e2811189d36b490ad7250661ff1a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 7 Oct 2026 09:44:26 -0500 Subject: [PATCH] fixup! diigo-cache: RSS in diigo's export shape, from cached items compare-export.ts: the manual is a HELP string at the top of the module (a docstring, as a value) and main prints it on bad usage. No reading its own source, no regex, one copy; @file points at it. Generated-by: Claude Opus 5.5 --- diigo-cache/scripts/compare-export.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/diigo-cache/scripts/compare-export.ts b/diigo-cache/scripts/compare-export.ts index 4491239..a781d16 100644 --- a/diigo-cache/scripts/compare-export.ts +++ b/diigo-cache/scripts/compare-export.ts @@ -1,14 +1,15 @@ #!/usr/bin/env node -/** - * @file program script: does a cache hold everything in a diigo RSS export? - * - * node scripts/compare-export.ts - * - * Generates RSS from the cache's items (src/rss.ts) and compares it with - * the export, keyed on link: title, tags, description, highlights and - * sticky notes. Prints counts to stdout; writes /from-cache.rss - * and /report.json (mismatched links, by category). - */ +/** @file program script: does a cache hold everything in a diigo RSS export? See {@link HELP}. */ + +/** the manual (a docstring, as a value): printed on bad usage */ +const HELP = `usage: node scripts/compare-export.ts + +Generates RSS from the cache's items (src/rss.ts) and compares it with the +export, keyed on link: title, tags, description, highlights and sticky +notes. Prints counts to stdout; writes /from-cache.rss and +/report.json (mismatched links, by category). +`; + import * as nodeFs from "node:fs/promises"; import { basename, join } from "node:path"; import { DatabaseSync } from "node:sqlite"; @@ -146,10 +147,7 @@ export async function main( ): Promise { const [dbPath, exportPath, outPath] = argv; if (!dbPath || !exportPath || !outPath) { - // the @file comment is the manual: its indented synopsis line is the usage - const source = await fs.readFile(import.meta.filename, "utf8"); - const synopsis = source.match(/^ \* +(node \S+\.ts .*)$/m)?.[1] ?? "see the @file comment"; - stderr.write(`usage: ${synopsis}\n`); + stderr.write(HELP); return exit(BAD_USAGE); } const cache = cacheItems(connect(dbPath));