Skip to content

Commit

Permalink
chore: improve code quality (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubogdan authored Apr 26, 2022
1 parent 90170b9 commit 636f456
Show file tree
Hide file tree
Showing 17 changed files with 1,007 additions and 572 deletions.
36 changes: 18 additions & 18 deletions cmd/swag/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,36 +112,36 @@ var initFlags = []cli.Flag{
},
}

func initAction(c *cli.Context) error {
strategy := c.String(propertyStrategyFlag)
func initAction(ctx *cli.Context) error {
strategy := ctx.String(propertyStrategyFlag)

switch strategy {
case swag.CamelCase, swag.SnakeCase, swag.PascalCase:
default:
return fmt.Errorf("not supported %s propertyStrategy", strategy)
}

outputTypes := strings.Split(c.String(outputTypesFlag), ",")
outputTypes := strings.Split(ctx.String(outputTypesFlag), ",")
if len(outputTypes) == 0 {
return fmt.Errorf("no output types specified")
}

return gen.New().Build(&gen.Config{
SearchDir: c.String(searchDirFlag),
Excludes: c.String(excludeFlag),
MainAPIFile: c.String(generalInfoFlag),
SearchDir: ctx.String(searchDirFlag),
Excludes: ctx.String(excludeFlag),
MainAPIFile: ctx.String(generalInfoFlag),
PropNamingStrategy: strategy,
OutputDir: c.String(outputFlag),
OutputDir: ctx.String(outputFlag),
OutputTypes: outputTypes,
ParseVendor: c.Bool(parseVendorFlag),
ParseDependency: c.Bool(parseDependencyFlag),
MarkdownFilesDir: c.String(markdownFilesFlag),
ParseInternal: c.Bool(parseInternalFlag),
GeneratedTime: c.Bool(generatedTimeFlag),
CodeExampleFilesDir: c.String(codeExampleFilesFlag),
ParseDepth: c.Int(parseDepthFlag),
InstanceName: c.String(instanceNameFlag),
OverridesFile: c.String(overridesFileFlag),
ParseVendor: ctx.Bool(parseVendorFlag),
ParseDependency: ctx.Bool(parseDependencyFlag),
MarkdownFilesDir: ctx.String(markdownFilesFlag),
ParseInternal: ctx.Bool(parseInternalFlag),
GeneratedTime: ctx.Bool(generatedTimeFlag),
CodeExampleFilesDir: ctx.String(codeExampleFilesFlag),
ParseDepth: ctx.Int(parseDepthFlag),
InstanceName: ctx.String(instanceNameFlag),
OverridesFile: ctx.String(overridesFileFlag),
})
}

Expand Down Expand Up @@ -192,8 +192,8 @@ func main() {
},
},
}
err := app.Run(os.Args)
if err != nil {

if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
Loading

0 comments on commit 636f456

Please sign in to comment.