Skip to content

Commit 636f456

Browse files
authored
chore: improve code quality (#1184)
1 parent 90170b9 commit 636f456

17 files changed

Lines changed: 1007 additions & 572 deletions

cmd/swag/main.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,36 +112,36 @@ var initFlags = []cli.Flag{
112112
},
113113
}
114114

115-
func initAction(c *cli.Context) error {
116-
strategy := c.String(propertyStrategyFlag)
115+
func initAction(ctx *cli.Context) error {
116+
strategy := ctx.String(propertyStrategyFlag)
117117

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

124-
outputTypes := strings.Split(c.String(outputTypesFlag), ",")
124+
outputTypes := strings.Split(ctx.String(outputTypesFlag), ",")
125125
if len(outputTypes) == 0 {
126126
return fmt.Errorf("no output types specified")
127127
}
128128

129129
return gen.New().Build(&gen.Config{
130-
SearchDir: c.String(searchDirFlag),
131-
Excludes: c.String(excludeFlag),
132-
MainAPIFile: c.String(generalInfoFlag),
130+
SearchDir: ctx.String(searchDirFlag),
131+
Excludes: ctx.String(excludeFlag),
132+
MainAPIFile: ctx.String(generalInfoFlag),
133133
PropNamingStrategy: strategy,
134-
OutputDir: c.String(outputFlag),
134+
OutputDir: ctx.String(outputFlag),
135135
OutputTypes: outputTypes,
136-
ParseVendor: c.Bool(parseVendorFlag),
137-
ParseDependency: c.Bool(parseDependencyFlag),
138-
MarkdownFilesDir: c.String(markdownFilesFlag),
139-
ParseInternal: c.Bool(parseInternalFlag),
140-
GeneratedTime: c.Bool(generatedTimeFlag),
141-
CodeExampleFilesDir: c.String(codeExampleFilesFlag),
142-
ParseDepth: c.Int(parseDepthFlag),
143-
InstanceName: c.String(instanceNameFlag),
144-
OverridesFile: c.String(overridesFileFlag),
136+
ParseVendor: ctx.Bool(parseVendorFlag),
137+
ParseDependency: ctx.Bool(parseDependencyFlag),
138+
MarkdownFilesDir: ctx.String(markdownFilesFlag),
139+
ParseInternal: ctx.Bool(parseInternalFlag),
140+
GeneratedTime: ctx.Bool(generatedTimeFlag),
141+
CodeExampleFilesDir: ctx.String(codeExampleFilesFlag),
142+
ParseDepth: ctx.Int(parseDepthFlag),
143+
InstanceName: ctx.String(instanceNameFlag),
144+
OverridesFile: ctx.String(overridesFileFlag),
145145
})
146146
}
147147

@@ -192,8 +192,8 @@ func main() {
192192
},
193193
},
194194
}
195-
err := app.Run(os.Args)
196-
if err != nil {
195+
196+
if err := app.Run(os.Args); err != nil {
197197
log.Fatal(err)
198198
}
199199
}

0 commit comments

Comments
 (0)