1 | const { l10n, print, splitKeywords, fetchThreadLikesByKeywords, Thread } = require('../..');
|
2 |
|
3 | exports.command = 'search <subscribable-string>';
|
4 |
|
5 | exports.aliases = ['find'];
|
6 |
|
7 | exports.desc = l10n('CMD_FIND_DESC');
|
8 |
|
9 | exports.builder = (yargs) => {
|
10 | yargs
|
11 | .usage(l10n('CMD_FIND_USAGE'))
|
12 | .positional('subscribable-string', {
|
13 | alias: 'ss',
|
14 | type: 'string',
|
15 | });
|
16 | };
|
17 |
|
18 | exports.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 |
|
28 | threadLikes.forEach((th) => {
|
29 | Thread.parseEpisodeFromTitle(th.title);
|
30 | });
|
31 |
|
32 | process.exit(0);
|
33 | };
|