@@ -340,14 +340,16 @@ function makeOptionDefinitions(targetLanguages: readonly TargetLanguage[]): Opti
340340 alias : "o" ,
341341 type : String ,
342342 typeLabel : "FILE" ,
343- description : "The output file. Determines --lang and --top-level."
343+ description : "The output file. Determines --lang and --top-level." ,
344+ kind : "cli"
344345 } ,
345346 {
346347 name : "top-level" ,
347348 alias : "t" ,
348349 type : String ,
349350 typeLabel : "NAME" ,
350- description : "The name for the top level type."
351+ description : "The name for the top level type." ,
352+ kind : "cli"
351353 }
352354 ] ;
353355 const lang : OptionDefinition [ ] =
@@ -359,7 +361,8 @@ function makeOptionDefinitions(targetLanguages: readonly TargetLanguage[]): Opti
359361 alias : "l" ,
360362 type : String ,
361363 typeLabel : "LANG" ,
362- description : "The target language."
364+ description : "The target language." ,
365+ kind : "cli"
363366 }
364367 ] ;
365368 const afterLang : OptionDefinition [ ] = [
@@ -369,29 +372,33 @@ function makeOptionDefinitions(targetLanguages: readonly TargetLanguage[]): Opti
369372 type : String ,
370373 defaultValue : undefined ,
371374 typeLabel : "SRC_LANG" ,
372- description : "The source language (default is json)."
375+ description : "The source language (default is json)." ,
376+ kind : "cli"
373377 } ,
374378 {
375379 name : "src" ,
376380 type : String ,
377381 multiple : true ,
378382 defaultOption : true ,
379383 typeLabel : "FILE|URL|DIRECTORY" ,
380- description : "The file, url, or data directory to type."
384+ description : "The file, url, or data directory to type." ,
385+ kind : "cli"
381386 } ,
382387 {
383388 name : "src-urls" ,
384389 type : String ,
385390 typeLabel : "FILE" ,
386- description : "Tracery grammar describing URLs to crawl."
391+ description : "Tracery grammar describing URLs to crawl." ,
392+ kind : "cli"
387393 }
388394 ] ;
389395 const inference : OptionDefinition [ ] = Array . from (
390396 mapMap ( mapFromObject ( inferenceFlags ) , ( flag , name ) => {
391397 return {
392398 name : dashedFromCamelCase ( negatedInferenceFlagName ( name ) ) ,
393399 type : Boolean ,
394- description : flag . negationDescription + "."
400+ description : flag . negationDescription + "." ,
401+ kind : "cli" as const
395402 } ;
396403 } ) . values ( )
397404 ) ;
@@ -400,85 +407,99 @@ function makeOptionDefinitions(targetLanguages: readonly TargetLanguage[]): Opti
400407 name : "graphql-schema" ,
401408 type : String ,
402409 typeLabel : "FILE" ,
403- description : "GraphQL introspection file."
410+ description : "GraphQL introspection file." ,
411+ kind : "cli"
404412 } ,
405413 {
406414 name : "graphql-introspect" ,
407415 type : String ,
408416 typeLabel : "URL" ,
409- description : "Introspect GraphQL schema from a server."
417+ description : "Introspect GraphQL schema from a server." ,
418+ kind : "cli"
410419 } ,
411420 {
412421 name : "http-method" ,
413422 type : String ,
414423 typeLabel : "METHOD" ,
415- description : "HTTP method to use for the GraphQL introspection query."
424+ description : "HTTP method to use for the GraphQL introspection query." ,
425+ kind : "cli"
416426 } ,
417427 {
418428 name : "http-header" ,
419429 type : String ,
420430 multiple : true ,
421431 typeLabel : "HEADER" ,
422- description : "Header(s) to attach to all HTTP requests, including the GraphQL introspection query."
432+ description : "Header(s) to attach to all HTTP requests, including the GraphQL introspection query." ,
433+ kind : "cli"
423434 } ,
424435 {
425436 name : "additional-schema" ,
426437 alias : "S" ,
427438 type : String ,
428439 multiple : true ,
429440 typeLabel : "FILE" ,
430- description : "Register the $id's of additional JSON Schema files."
441+ description : "Register the $id's of additional JSON Schema files." ,
442+ kind : "cli"
431443 } ,
432444 {
433445 name : "no-render" ,
434446 type : Boolean ,
435- description : "Don't render output."
447+ description : "Don't render output." ,
448+ kind : "cli"
436449 } ,
437450 {
438451 name : "alphabetize-properties" ,
439452 type : Boolean ,
440- description : "Alphabetize order of class properties."
453+ description : "Alphabetize order of class properties." ,
454+ kind : "cli"
441455 } ,
442456 {
443457 name : "all-properties-optional" ,
444458 type : Boolean ,
445- description : "Make all class properties optional."
459+ description : "Make all class properties optional." ,
460+ kind : "cli"
446461 } ,
447462 {
448463 name : "build-markov-chain" ,
449464 type : String ,
450465 typeLabel : "FILE" ,
451- description : "Markov chain corpus filename."
466+ description : "Markov chain corpus filename." ,
467+ kind : "cli"
452468 } ,
453469 {
454470 name : "quiet" ,
455471 type : Boolean ,
456- description : "Don't show issues in the generated code."
472+ description : "Don't show issues in the generated code." ,
473+ kind : "cli"
457474 } ,
458475 {
459476 name : "debug" ,
460477 type : String ,
461478 typeLabel : "OPTIONS or all" ,
462479 description :
463- "Comma separated debug options: print-graph, print-reconstitution, print-gather-names, print-transformations, print-schema-resolving, print-times, provenance"
480+ "Comma separated debug options: print-graph, print-reconstitution, print-gather-names, print-transformations, print-schema-resolving, print-times, provenance" ,
481+ kind : "cli"
464482 } ,
465483 {
466484 name : "telemetry" ,
467485 type : String ,
468486 typeLabel : "enable|disable" ,
469- description : "Enable anonymous telemetry to help improve quicktype"
487+ description : "Enable anonymous telemetry to help improve quicktype" ,
488+ kind : "cli"
470489 } ,
471490 {
472491 name : "help" ,
473492 alias : "h" ,
474493 type : Boolean ,
475- description : "Get some help."
494+ description : "Get some help." ,
495+ kind : "cli"
476496 } ,
477497 {
478498 name : "version" ,
479499 alias : "v" ,
480500 type : Boolean ,
481- description : "Display the version of quicktype"
501+ description : "Display the version of quicktype" ,
502+ kind : "cli"
482503 }
483504 ] ;
484505 return beforeLang . concat ( lang , afterLang , inference , afterInference ) ;
@@ -600,9 +621,7 @@ export function parseCLIOptions(argv: string[], targetLanguage?: TargetLanguage)
600621// according to each option definition's `renderer` field. If `partial` is false this
601622// will throw if it encounters an unknown option.
602623function parseOptions ( definitions : OptionDefinition [ ] , argv : string [ ] , partial : boolean ) : Partial < CLIOptions > {
603- // FIXME: update this when options strongly typed
604- // eslint-disable-next-line @typescript-eslint/no-explicit-any
605- let opts : { [ key : string ] : any } ;
624+ let opts : commandLineArgs . CommandLineOptions ;
606625 try {
607626 opts = commandLineArgs ( definitions , { argv, partial } ) ;
608627 } catch ( e ) {
@@ -623,12 +642,14 @@ function parseOptions(definitions: OptionDefinition[], argv: string[], partial:
623642 if ( ! hasOwnProperty ( opts , optionDefinition . name ) ) {
624643 continue ;
625644 }
626- const v = opts [ optionDefinition . name ] as string ;
627- if ( optionDefinition . name in options . rendererOptions ) {
628- ( options . rendererOptions as Record < typeof optionDefinition . name , unknown > ) [ optionDefinition . name ] = v ;
645+
646+ const optionValue = opts [ optionDefinition . name ] as string ;
647+ if ( optionDefinition . kind !== "cli" ) {
648+ ( options . rendererOptions as Record < typeof optionDefinition . name , unknown > ) [ optionDefinition . name ] =
649+ optionValue ;
629650 } else {
630651 const k = _ . lowerFirst ( optionDefinition . name . split ( "-" ) . map ( _ . upperFirst ) . join ( "" ) ) ;
631- options [ k ] = v ;
652+ options [ k ] = optionValue ;
632653 }
633654 }
634655
0 commit comments