-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.js
More file actions
43 lines (35 loc) · 1.11 KB
/
scan.js
File metadata and controls
43 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
import "dotenv/config";
import minimist from "minimist";
import { scanAll, formatScanResults } from "./lib/scan.js";
const argv = minimist(process.argv.slice(2), {
string: ["source"],
default: { limit: 10 },
});
function log(msg) {
const t = new Date().toTimeString().slice(0, 8);
console.log(`[${t}] ${msg}`);
}
const queries = (argv._ ?? []).map(s => String(s).trim()).filter(Boolean);
if (!queries.length) {
console.log(`
Usage: node scan.js [options] "Set or card name"
Options:
--source <api|pokebeach|pokemon> Limit to one source (default: all)
--limit <n> Max results per source (default: 10)
Examples:
node scan.js "Terastal Festival"
node scan.js --source pokebeach "Ninja Spinner"
node scan.js "Prismatic Evolutions" "Surging Sparks"
`);
process.exit(0);
}
const source = argv.source || null;
const limit = Number(argv.limit) || 10;
for (const query of queries) {
log(`Scanning for "${query}"...`);
const results = await scanAll(query, { log, limit, source });
console.log("");
console.log(formatScanResults(query, results));
console.log("");
}