@@ -22,6 +22,7 @@ export interface CLIArgs {
2222 skipPixabay : boolean
2323 skipWikipedia : boolean
2424 skipGooglePlaces : boolean
25+ mediaLibraryPath : string | undefined
2526 quiet : boolean
2627 verbose : boolean
2728 dryRun : boolean
@@ -151,6 +152,10 @@ function parseCommaSeparated(value: unknown): string[] {
151152 . filter ( Boolean )
152153}
153154
155+ function parseOptionalString ( value : unknown ) : string | undefined {
156+ return typeof value === 'string' ? value : undefined
157+ }
158+
154159function parseConfigAction ( action : string | undefined ) : 'list' | 'set' | 'unset' {
155160 if ( action === 'set' || action === 'unset' ) {
156161 return action
@@ -173,30 +178,30 @@ function buildCLIArgs(commandName: string, input: string, opts: Record<string, u
173178 skipPixabay : opts . skipPixabay === true ,
174179 skipWikipedia : opts . skipWikipedia === true ,
175180 skipGooglePlaces : opts . skipGooglePlaces === true ,
181+ mediaLibraryPath : parseOptionalString ( opts . mediaLibraryPath ) ,
176182 quiet : opts . quiet === true ,
177183 verbose : opts . verbose === true ,
178184 dryRun : opts . dryRun === true ,
179185 debug : opts . debug === true ,
180186 maxResults : Number . parseInt ( String ( opts . maxResults ?? '10' ) , 10 ) ,
181187 maxMessages : opts . maxMessages ? Number . parseInt ( String ( opts . maxMessages ) , 10 ) : undefined ,
182188 method : parseMethod ( opts . method ) ,
183- jsonOutput :
184- opts . json === true ? 'stdout' : typeof opts . json === 'string' ? opts . json : undefined ,
185- homeCountry : typeof opts . homeCountry === 'string' ? opts . homeCountry : undefined ,
186- timezone : typeof opts . timezone === 'string' ? opts . timezone : undefined ,
189+ jsonOutput : opts . json === true ? 'stdout' : parseOptionalString ( opts . json ) ,
190+ homeCountry : parseOptionalString ( opts . homeCountry ) ,
191+ timezone : parseOptionalString ( opts . timezone ) ,
187192 scrapeConcurrency : Number . parseInt ( String ( opts . concurrency ?? '5' ) , 10 ) ,
188193 scrapeTimeout : Number . parseInt ( String ( opts . timeout ?? '4000' ) , 10 ) ,
189194 noCache : opts . cache === false ,
190- cacheDir : typeof opts . cacheDir === 'string' ? opts . cacheDir : undefined ,
191- configFile : typeof opts . configFile === 'string' ? opts . configFile : undefined ,
195+ cacheDir : parseOptionalString ( opts . cacheDir ) ,
196+ configFile : parseOptionalString ( opts . configFile ) ,
192197 showAll : opts . all === true ,
193198
194199 // Common export settings
195200 exportCategories : parseCommaSeparated ( opts . exportCategories ) ,
196201 exportCountries : parseCommaSeparated ( opts . exportCountries ) ,
197202 exportFrom : parseCommaSeparated ( opts . exportFrom ) ,
198- exportStartDate : typeof opts . exportStartDate === 'string' ? opts . exportStartDate : undefined ,
199- exportEndDate : typeof opts . exportEndDate === 'string' ? opts . exportEndDate : undefined ,
203+ exportStartDate : parseOptionalString ( opts . exportStartDate ) ,
204+ exportEndDate : parseOptionalString ( opts . exportEndDate ) ,
200205 exportMinScore : parseOptionalNumber ( opts . exportMinScore ) ,
201206 exportOnlyLocations : opts . exportOnlyLocations === true ,
202207 exportOnlyGeneric : opts . exportOnlyGeneric === true ,
@@ -211,25 +216,25 @@ function buildCLIArgs(commandName: string, input: string, opts: Record<string, u
211216 opts . pdfGroupByCategory ,
212217 opts . pdfNoGroupByCategory
213218 ) ,
214- pdfPageSize : typeof opts . pdfPageSize === 'string' ? opts . pdfPageSize : undefined ,
215- pdfTitle : typeof opts . pdfTitle === 'string' ? opts . pdfTitle : undefined ,
216- pdfSubtitle : typeof opts . pdfSubtitle === 'string' ? opts . pdfSubtitle : undefined ,
219+ pdfPageSize : parseOptionalString ( opts . pdfPageSize ) ,
220+ pdfTitle : parseOptionalString ( opts . pdfTitle ) ,
221+ pdfSubtitle : parseOptionalString ( opts . pdfSubtitle ) ,
217222 pdfCategories : parseCommaSeparated ( opts . pdfCategories ) ,
218223 pdfCountries : parseCommaSeparated ( opts . pdfCountries ) ,
219224 pdfFrom : parseCommaSeparated ( opts . pdfFrom ) ,
220- pdfStartDate : typeof opts . pdfStartDate === 'string' ? opts . pdfStartDate : undefined ,
221- pdfEndDate : typeof opts . pdfEndDate === 'string' ? opts . pdfEndDate : undefined ,
225+ pdfStartDate : parseOptionalString ( opts . pdfStartDate ) ,
226+ pdfEndDate : parseOptionalString ( opts . pdfEndDate ) ,
222227 pdfMinScore : parseOptionalNumber ( opts . pdfMinScore ) ,
223228 pdfOnlyLocations : opts . pdfOnlyLocations === true ,
224229 pdfOnlyGeneric : opts . pdfOnlyGeneric === true ,
225230 pdfMaxActivities : Number . parseInt ( String ( opts . pdfMaxActivities ?? '0' ) , 10 ) ,
226231 pdfSort : parseSortOrder ( opts . pdfSort ) ,
227232
228233 // Map-specific settings
229- mapDefaultStyle : typeof opts . mapDefaultStyle === 'string' ? opts . mapDefaultStyle : undefined ,
234+ mapDefaultStyle : parseOptionalString ( opts . mapDefaultStyle ) ,
230235
231236 // Export subcommand settings
232- exportOutput : typeof opts . output === 'string' ? opts . output : undefined ,
237+ exportOutput : parseOptionalString ( opts . output ) ,
233238 exportFormat : undefined ,
234239
235240 configAction : 'list' ,
0 commit comments