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));