Skip to content

Commit

Permalink
feat: add version command line arg
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvynl committed Mar 26, 2024
1 parent 5e2ca00 commit f5f10e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Usage goctl-openapi:
serialization format, "json" or "yaml", default "json".
-pretty
pretty print of json.
-version
show version and exit.
```

Usage example.
Expand Down
14 changes: 11 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@ import (
"fmt"
"os"
"path"
"runtime"
"strings"

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

const Version = "v1.6.0"

var (
output = flag.String("filename", "", `openapi file name, default "openapi.json", "-" will output to stdout.`)
format = flag.String("format", "", `serialization format, "json" or "yaml", default "json".`)
pretty = flag.Bool("pretty", false, `pretty print of json.`)
version = flag.Bool("version", false, `show version and exit.`)
output = flag.String("filename", "", `openapi file name, default "openapi.json", "-" will output to stdout.`)
format = flag.String("format", "", `serialization format, "json" or "yaml", default "json".`)
pretty = flag.Bool("pretty", false, `pretty print of json.`)
)

func main() {
flag.Parse()
if *version {
fmt.Printf("goctl-openapi %s %s/%s\n", Version, runtime.GOOS, runtime.GOARCH)
return
}

p, err := plugin.NewPlugin()
if err != nil {
Expand Down

0 comments on commit f5f10e8

Please sign in to comment.