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
This commit is contained in:
dckc committed 2026-10-07 09:44:26 -05:00
1 parent 2055e8c1c9
commit 697fd95514
1 file changed
+12 -14
+12 -14
View File
@@ -1,14 +1,15 @@
#!/usr/bin/env node #!/usr/bin/env node
/** /** @file program script: does a cache hold everything in a diigo RSS export? See {@link HELP}. */
* @file program script: does a cache hold everything in a diigo RSS export?
* /** the manual (a docstring, as a value): printed on bad usage */
* node scripts/compare-export.ts <cache.sqlite> <export.xml> <out-dir> const HELP = `usage: node scripts/compare-export.ts <cache.sqlite> <export.xml> <out-dir>
*
* Generates RSS from the cache's items (src/rss.ts) and compares it with Generates RSS from the cache's items (src/rss.ts) and compares it with the
* the export, keyed on link: title, tags, description, highlights and export, keyed on link: title, tags, description, highlights and sticky
* sticky notes. Prints counts to stdout; writes <out-dir>/from-cache.rss notes. Prints counts to stdout; writes <out-dir>/from-cache.rss and
* and <out-dir>/report.json (mismatched links, by category). <out-dir>/report.json (mismatched links, by category).
*/ `;
import * as nodeFs from "node:fs/promises"; import * as nodeFs from "node:fs/promises";
import { basename, join } from "node:path"; import { basename, join } from "node:path";
import { DatabaseSync } from "node:sqlite"; import { DatabaseSync } from "node:sqlite";
@@ -146,10 +147,7 @@ export async function main(
): Promise<void> { ): Promise<void> {
const [dbPath, exportPath, outPath] = argv; const [dbPath, exportPath, outPath] = argv;
if (!dbPath || !exportPath || !outPath) { if (!dbPath || !exportPath || !outPath) {
// the @file comment is the manual: its indented synopsis line is the usage stderr.write(HELP);
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`);
return exit(BAD_USAGE); return exit(BAD_USAGE);
} }
const cache = cacheItems(connect(dbPath)); const cache = cacheItems(connect(dbPath));