diff --git a/README.md b/README.md index bc4d974..761df84 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/main.go b/main.go index 665bb2d..4b82919 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path" + "runtime" "strings" "github.com/jayvynl/goctl-openapi/oas3" @@ -13,14 +14,21 @@ import ( "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 {