Skip to content

Commit f5f10e8

Browse files
committed
feat: add version command line arg
1 parent 5e2ca00 commit f5f10e8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Usage goctl-openapi:
3333
serialization format, "json" or "yaml", default "json".
3434
-pretty
3535
pretty print of json.
36+
-version
37+
show version and exit.
3638
```
3739

3840
Usage example.

main.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,29 @@ import (
66
"fmt"
77
"os"
88
"path"
9+
"runtime"
910
"strings"
1011

1112
"github.com/jayvynl/goctl-openapi/oas3"
1213
"github.com/zeromicro/go-zero/tools/goctl/plugin"
1314
"gopkg.in/yaml.v2"
1415
)
1516

17+
const Version = "v1.6.0"
18+
1619
var (
17-
output = flag.String("filename", "", `openapi file name, default "openapi.json", "-" will output to stdout.`)
18-
format = flag.String("format", "", `serialization format, "json" or "yaml", default "json".`)
19-
pretty = flag.Bool("pretty", false, `pretty print of json.`)
20+
version = flag.Bool("version", false, `show version and exit.`)
21+
output = flag.String("filename", "", `openapi file name, default "openapi.json", "-" will output to stdout.`)
22+
format = flag.String("format", "", `serialization format, "json" or "yaml", default "json".`)
23+
pretty = flag.Bool("pretty", false, `pretty print of json.`)
2024
)
2125

2226
func main() {
2327
flag.Parse()
28+
if *version {
29+
fmt.Printf("goctl-openapi %s %s/%s\n", Version, runtime.GOOS, runtime.GOARCH)
30+
return
31+
}
2432

2533
p, err := plugin.NewPlugin()
2634
if err != nil {

0 commit comments

Comments
 (0)