MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / updateOldConfigFromFlags

Function updateOldConfigFromFlags

cmd/oapi-codegen/oapi-codegen.go:480–510  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

478// a zerovalue in the configuration file will be replaced with the flag
479// value, this means that the config file overrides flag values.
480func 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.
513func generationTargets(cfg *codegen.Configuration, targets []string) error {

Callers 1

newConfigFromOldConfigFunction · 0.85

Calls 3

ParseCommandLineListFunction · 0.92
ParseCommandlineMapFunction · 0.92
errExitFunction · 0.85

Tested by

no test coverage detected