@@ -18,6 +18,7 @@ const (
18
18
searchDirFlag = "dir"
19
19
excludeFlag = "exclude"
20
20
generalInfoFlag = "generalInfo"
21
+ pipeFlag = "pipe"
21
22
propertyStrategyFlag = "propertyStrategy"
22
23
outputFlag = "output"
23
24
outputTypesFlag = "outputTypes"
@@ -195,11 +196,17 @@ func initAction(ctx *cli.Context) error {
195
196
if ctx .IsSet (templateDelimsFlag ) {
196
197
delims := strings .Split (ctx .String (templateDelimsFlag ), "," )
197
198
if len (delims ) != 2 {
198
- return fmt .Errorf ("exactly two template delimiters must be provided, comma separated" )
199
+ return fmt .Errorf (
200
+ "exactly two template delimiters must be provided, comma separated" ,
201
+ )
199
202
} else if delims [0 ] == delims [1 ] {
200
203
return fmt .Errorf ("template delimiters must be different" )
201
204
}
202
- leftDelim , rightDelim = strings .TrimSpace (delims [0 ]), strings .TrimSpace (delims [1 ])
205
+ leftDelim , rightDelim = strings .TrimSpace (
206
+ delims [0 ],
207
+ ), strings .TrimSpace (
208
+ delims [1 ],
209
+ )
203
210
}
204
211
205
212
outputTypes := strings .Split (ctx .String (outputTypesFlag ), "," )
@@ -211,9 +218,14 @@ func initAction(ctx *cli.Context) error {
211
218
logger = log .New (io .Discard , "" , log .LstdFlags )
212
219
}
213
220
214
- collectionFormat := swag .TransToValidCollectionFormat (ctx .String (collectionFormatFlag ))
221
+ collectionFormat := swag .TransToValidCollectionFormat (
222
+ ctx .String (collectionFormatFlag ),
223
+ )
215
224
if collectionFormat == "" {
216
- return fmt .Errorf ("not supported %s collectionFormat" , ctx .String (collectionFormat ))
225
+ return fmt .Errorf (
226
+ "not supported %s collectionFormat" ,
227
+ ctx .String (collectionFormat ),
228
+ )
217
229
}
218
230
219
231
var pdv = ctx .Int (parseDependencyLevelFlag )
@@ -269,6 +281,11 @@ func main() {
269
281
Aliases : []string {"f" },
270
282
Usage : "format swag comments" ,
271
283
Action : func (c * cli.Context ) error {
284
+
285
+ if c .Bool (pipeFlag ) {
286
+ return format .New ().Run (os .Stdin , os .Stdout )
287
+ }
288
+
272
289
searchDir := c .String (searchDirFlag )
273
290
excludeDir := c .String (excludeFlag )
274
291
mainFile := c .String (generalInfoFlag )
@@ -296,6 +313,12 @@ func main() {
296
313
Value : "main.go" ,
297
314
Usage : "Go file path in which 'swagger general API Info' is written" ,
298
315
},
316
+ & cli.BoolFlag {
317
+ Name : "pipe" ,
318
+ Aliases : []string {"p" },
319
+ Value : false ,
320
+ Usage : "Read from stdin, write to stdout." ,
321
+ },
299
322
},
300
323
},
301
324
}
0 commit comments