updateConfigFromFlags updates a loaded configuration from flags. Flags override anything in the file. We generate errors for any unsupported command line flags.
(cfg *configuration)
| 420 | // override anything in the file. We generate errors for any unsupported |
| 421 | // command line flags. |
| 422 | func updateConfigFromFlags(cfg *configuration) error { |
| 423 | if flagPackageName != "" { |
| 424 | cfg.PackageName = flagPackageName |
| 425 | } |
| 426 | |
| 427 | if flagGenerate != "types,client,server,spec" { |
| 428 | // Override generation and output options from generate command line flag. |
| 429 | if err := generationTargets(&cfg.Configuration, util.ParseCommandLineList(flagGenerate)); err != nil { |
| 430 | return err |
| 431 | } |
| 432 | } |
| 433 | if flagIncludeTags != "" { |
| 434 | cfg.OutputOptions.IncludeTags = util.ParseCommandLineList(flagIncludeTags) |
| 435 | } |
| 436 | if flagExcludeTags != "" { |
| 437 | cfg.OutputOptions.ExcludeTags = util.ParseCommandLineList(flagExcludeTags) |
| 438 | } |
| 439 | if flagIncludeOperationIDs != "" { |
| 440 | cfg.OutputOptions.IncludeOperationIDs = util.ParseCommandLineList(flagIncludeOperationIDs) |
| 441 | } |
| 442 | if flagExcludeOperationIDs != "" { |
| 443 | cfg.OutputOptions.ExcludeOperationIDs = util.ParseCommandLineList(flagExcludeOperationIDs) |
| 444 | } |
| 445 | |
| 446 | if flagTemplatesDir != "" { |
| 447 | templates, err := loadTemplateOverrides(flagTemplatesDir) |
| 448 | if err != nil { |
| 449 | return fmt.Errorf("load templates from %q: %w", flagTemplatesDir, err) |
| 450 | } |
| 451 | cfg.OutputOptions.UserTemplates = templates |
| 452 | } |
| 453 | if flagImportMapping != "" { |
| 454 | var err error |
| 455 | cfg.ImportMapping, err = util.ParseCommandlineMap(flagImportMapping) |
| 456 | if err != nil { |
| 457 | return err |
| 458 | } |
| 459 | } |
| 460 | if flagExcludeSchemas != "" { |
| 461 | cfg.OutputOptions.ExcludeSchemas = util.ParseCommandLineList(flagExcludeSchemas) |
| 462 | } |
| 463 | if flagResponseTypeSuffix != "" { |
| 464 | cfg.OutputOptions.ResponseTypeSuffix = flagResponseTypeSuffix |
| 465 | } |
| 466 | if flagAliasTypes { |
| 467 | return fmt.Errorf("--alias-types isn't supported any more") |
| 468 | } |
| 469 | |
| 470 | if cfg.OutputFile == "" { |
| 471 | cfg.OutputFile = flagOutputFile |
| 472 | } |
| 473 | |
| 474 | return nil |
| 475 | } |
| 476 | |
| 477 | // updateOldConfigFromFlags parses the flags and the config file. Anything which is |
| 478 | // a zerovalue in the configuration file will be replaced with the flag |
no test coverage detected