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:
1 parent
2055e8c1c9
commit
697fd95514
1 file changed
+12
-14
@@ -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 <cache.sqlite> <export.xml> <out-dir>
|
||||
*
|
||||
* 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 <out-dir>/from-cache.rss
|
||||
* and <out-dir>/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 <cache.sqlite> <export.xml> <out-dir>
|
||||
|
||||
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 <out-dir>/from-cache.rss and
|
||||
<out-dir>/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<void> {
|
||||
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));
|
||||
|
||||
Reference in new issue
Block a user