updateOldConfigFromFlags parses the flags and the config file. Anything which is a zerovalue in the configuration file will be replaced with the flag value, this means that the config file overrides flag values.
(cfg oldConfiguration)
| 478 | // a zerovalue in the configuration file will be replaced with the flag |
| 479 | // value, this means that the config file overrides flag values. |
| 480 | func updateOldConfigFromFlags(cfg oldConfiguration) oldConfiguration { |
| 481 | if cfg.PackageName == "" { |
| 482 | cfg.PackageName = flagPackageName |
| 483 | } |
| 484 | if cfg.GenerateTargets == nil { |
| 485 | cfg.GenerateTargets = util.ParseCommandLineList(flagGenerate) |
| 486 | } |
| 487 | if cfg.IncludeTags == nil { |
| 488 | cfg.IncludeTags = util.ParseCommandLineList(flagIncludeTags) |
| 489 | } |
| 490 | if cfg.ExcludeTags == nil { |
| 491 | cfg.ExcludeTags = util.ParseCommandLineList(flagExcludeTags) |
| 492 | } |
| 493 | if cfg.TemplatesDir == "" { |
| 494 | cfg.TemplatesDir = flagTemplatesDir |
| 495 | } |
| 496 | if cfg.ImportMapping == nil && flagImportMapping != "" { |
| 497 | var err error |
| 498 | cfg.ImportMapping, err = util.ParseCommandlineMap(flagImportMapping) |
| 499 | if err != nil { |
| 500 | errExit("error parsing import-mapping: %s\n", err) |
| 501 | } |
| 502 | } |
| 503 | if cfg.ExcludeSchemas == nil { |
| 504 | cfg.ExcludeSchemas = util.ParseCommandLineList(flagExcludeSchemas) |
| 505 | } |
| 506 | if cfg.OutputFile == "" { |
| 507 | cfg.OutputFile = flagOutputFile |
| 508 | } |
| 509 | return cfg |
| 510 | } |
| 511 | |
| 512 | // generationTargets sets cfg options based on the generation targets. |
| 513 | func generationTargets(cfg *codegen.Configuration, targets []string) error { |
no test coverage detected