Skip to content

Commit 95cb54f

Browse files
committed
feat: multiple brands flag
1 parent afd550f commit 95cb54f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pnpm crawl -- --year 2020,2022,2024 # Anos específicos
4646
pnpm crawl -- --month 1-6 # Range de meses
4747
pnpm crawl -- --year 2023-2024 --month 1,6,12 # Combinar filtros
4848
pnpm crawl -- --brand 59 # Marca específica (59 = VW)
49+
pnpm crawl -- --brand 21,22,59 # Múltiplas marcas
4950
pnpm crawl -- --brand 59 --model 5940 # Modelo específico
5051
pnpm crawl -- --brand 59 --model 5940,5941 # Múltiplos modelos
5152
pnpm crawl -- --reference 328 # Tabela de referência específica

src/crawler/processor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface CrawlOptions {
4545
referenceCode?: number;
4646
years?: number[];
4747
months?: number[];
48-
brandCode?: string;
48+
brandCodes?: string[];
4949
modelCodes?: string[];
5050
classify?: boolean;
5151
force?: boolean;
@@ -97,8 +97,8 @@ export async function crawl(options: CrawlOptions = {}): Promise<void> {
9797
// Phase 1: Crawl brands (always fetch - cheap API call)
9898
log(' Phase 1: Crawling brands...');
9999
const apiBrands = await fipeClient.getBrands(ref.Codigo);
100-
const filteredBrands = options.brandCode
101-
? apiBrands.filter((b) => b.Value === options.brandCode)
100+
const filteredBrands = options.brandCodes
101+
? apiBrands.filter((b) => options.brandCodes!.includes(b.Value))
102102
: apiBrands;
103103

104104
for (const b of filteredBrands) {

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ program
4343
.option('-r, --reference <code>', 'Specific reference table code')
4444
.option('-y, --year <year>', 'Year(s) to crawl (e.g., 2023, 2020-2023, or 2020,2022,2023)')
4545
.option('-M, --month <month>', 'Month(s) to crawl (e.g., 6, 1-6, or 1,3,6)')
46-
.option('-b, --brand <code>', 'Specific brand code')
46+
.option('-b, --brand <codes>', 'Brand code(s), comma-separated')
4747
.option('-m, --model <codes>', 'Model code(s), comma-separated (requires --brand)')
4848
.option('-c, --classify', 'Classify new models by segment using AI')
4949
.option('-f, --force', 'Re-fetch all data, ignoring sync status')
@@ -53,7 +53,7 @@ program
5353
referenceCode: options.reference ? parseInt(options.reference, 10) : undefined,
5454
years: options.year ? parseNumberList(options.year) : undefined,
5555
months: options.month ? parseNumberList(options.month) : undefined,
56-
brandCode: options.brand,
56+
brandCodes: options.brand ? parseCommaSeparated(options.brand) : undefined,
5757
modelCodes: options.model ? parseCommaSeparated(options.model) : undefined,
5858
classify: options.classify,
5959
force: options.force,

0 commit comments

Comments
 (0)