Skip to content

Commit 2b53106

Browse files
committed
Add 'fetch both' subcommand
1 parent 974b164 commit 2b53106

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/commands/fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const fetchCommand = new Command('fetch').description(
1212
'Download topic content from Grokipedia and Wikipedia for offline comparison',
1313
);
1414

15-
const registerSubcommand = (source: 'wiki' | 'grok', description: string): void => {
15+
const registerSubcommand = (source: 'wiki' | 'grok' | 'both', description: string): void => {
1616
fetchCommand
1717
.command(source)
1818
.description(description)
@@ -24,5 +24,6 @@ const registerSubcommand = (source: 'wiki' | 'grok', description: string): void
2424

2525
registerSubcommand('wiki', 'Fetch articles from Wikipedia');
2626
registerSubcommand('grok', 'Fetch articles from Grokipedia');
27+
registerSubcommand('both', 'Fetch articles from both Wikipedia and Grokipedia');
2728

2829
export default fetchCommand;

src/workflows/fetch-workflow.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import fetch from 'node-fetch';
1111
import fs from 'node:fs';
1212
import path from 'node:path';
1313
import TurndownService from 'turndown';
14-
import { ArticleMetadata, ExternalCitation } from '../parsers/shared/types';
1514
import { parseMarkdownStructuredArticle } from '../parsers/grok';
15+
import { ArticleMetadata, ExternalCitation } from '../parsers/shared/types';
1616
import { parseWikiArticle } from '../parsers/wiki';
1717
import { paths } from '../shared/paths';
1818
import { loadTopics, selectTopics, Topic } from '../shared/topics';
1919

20-
export type FetchSource = 'wiki' | 'grok';
20+
export type FetchSource = 'wiki' | 'grok' | 'both';
2121

2222
const WIKI_BASE_URL = 'https://en.wikipedia.org';
2323
const WIKI_API = `${WIKI_BASE_URL}/w/api.php`;
@@ -368,17 +368,17 @@ const fetchGrok = async (topic: Topic): Promise<void> => {
368368
console.log(`[grok] saved ${topic.id} -> ${target}`);
369369
};
370370

371-
export const runFetchWorkflow = async (
372-
source: 'wiki' | 'grok',
373-
topicId?: string,
374-
): Promise<void> => {
371+
export const runFetchWorkflow = async (source: FetchSource, topicId?: string): Promise<void> => {
375372
const topics = loadTopics();
376373
const selection = selectTopics(topics, topicId);
377374
for (const topic of selection) {
378375
try {
379376
if (source === 'wiki') {
380377
await fetchWiki(topic);
381-
} else {
378+
} else if (source === 'grok') {
379+
await fetchGrok(topic);
380+
} else if (source === 'both') {
381+
await fetchWiki(topic);
382382
await fetchGrok(topic);
383383
}
384384
} catch (error) {

0 commit comments

Comments
 (0)