UNPKG

833 BJavaScriptView Raw
1const { l10n, print, splitKeywords, fetchThreadLikesByKeywords, Thread } = require('../..');
2
3exports.command = 'search <subscribable-string>';
4
5exports.aliases = ['find'];
6
7exports.desc = l10n('CMD_FIND_DESC');
8
9exports.builder = (yargs) => {
10 yargs
11 .usage(l10n('CMD_FIND_USAGE'))
12 .positional('subscribable-string', {
13 alias: 'ss',
14 type: 'string',
15 });
16};
17
18exports.handler = async (argv) => {
19 const { keywords, unkeywords } = splitKeywords(argv.ss.split(','));
20 const threadLikes = await fetchThreadLikesByKeywords(keywords, unkeywords);
21 threadLikes.forEach((th) => {
22 print.log(th.title);
23 });
24 console.log();
25 print.log(l10n('CMD_FIND_TOTAL', { total: threadLikes.length }));
26
27 // precheck
28 threadLikes.forEach((th) => {
29 Thread.parseEpisodeFromTitle(th.title);
30 });
31
32 process.exit(0);
33};