Skip to content

Commit

Permalink
change the plugin parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
namtzigla committed Mar 20, 2019
1 parent 5d95800 commit 3aad2bc
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 40 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ documentation for the project can be found [Here](docs/index.md)
The documentation goes over the persist options, how to structure your proto file,
custom type mapping to/from the database, and spanner query parsing

## Version 4.0.0
Starting with this version we changed the command line parameters.
On the `--plugin_out` option you can add `path=source_relative` to make sure that all the generated files will be created on the current directory.
The default behaviour (don't specify the `path=source_relative`) will generate the files in the same directory with the source files or in a directory computed from the (persist.pkg) or go_package option.


## Version 3.0.0
- Complete rework of the plugin (check the [examples](https://github.com/tcncloud/protoc-gen-persist/tree/master/examples) directory for more info)

Expand Down
4 changes: 2 additions & 2 deletions generator/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (f *FileStruct) GetPersistPackageOption() string {
func (f *FileStruct) GetImplFileName(sourceRelative bool) string {
_, file := filepath.Split(f.Desc.GetName())
if sourceRelative {
return strings.Replace(file, ".proto", "persist.go", -1)
return strings.Replace(file, ".proto", ".persist.go", -1)
} else {
return strings.Join([]string{
f.GetImplDir(),
Expand Down Expand Up @@ -331,7 +331,7 @@ func (f *FileStruct) Process() error {
}
func (f *FileStruct) NeedImport(pkg string) bool {
if f.NotSameAsMyPackage(pkg) &&
(f.Opts.PersistLibRoot != pkg) &&
// (f.Opts.PersistLibRoot != pkg) &&
pkg != "" {
return true
}
Expand Down
6 changes: 2 additions & 4 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Generator struct {
Files *FileList
Response *plugin_go.CodeGeneratorResponse
SourceRelative bool
ImportPaths bool
// ImportPaths bool
}

func NewGenerator(request *plugin_go.CodeGeneratorRequest) *Generator {
Expand All @@ -58,13 +58,13 @@ func NewGenerator(request *plugin_go.CodeGeneratorRequest) *Generator {
ret.Files = NewFileList()
ret.Response = new(plugin_go.CodeGeneratorResponse)
ret.SourceRelative = false
ret.ImportPaths = false

return ret
}

func (g *Generator) CommandLineParameters(parameter string) error {
// parameter := g.OriginalRequest.GetParameter()
logrus.WithField("command line params", parameter).Info("command line parameters")
for _, p := range strings.Split(parameter, ",") {
logrus.WithField("p", p).Info("...")
if strings.Contains(p, "=") {
Expand All @@ -73,10 +73,8 @@ func (g *Generator) CommandLineParameters(parameter string) error {
case "paths":
if cmd[1] == "source_relative" {
g.SourceRelative = true
g.ImportPaths = false
} else {
g.SourceRelative = false
g.ImportPaths = true
}
}
}
Expand Down
45 changes: 11 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
module github.com/tcncloud/protoc-gen-persist

go 1.12

require (
cloud.google.com/go v0.35.0
contrib.go.opencensus.io/exporter/stackdriver v0.8.0 // indirect
git.apache.org/thrift.git v0.12.0 // indirect
github.com/Shopify/sarama v1.20.0 // indirect
github.com/aws/aws-sdk-go v1.16.15 // indirect
github.com/go-ini/ini v1.41.0 // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/gogo/protobuf v1.2.0 // indirect
github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
cloud.google.com/go v0.37.1
github.com/golang/protobuf v1.3.1
github.com/googleapis/gax-go v2.0.2+incompatible // indirect
github.com/grpc-ecosystem/grpc-gateway v1.6.4 // indirect
github.com/lib/pq v1.0.0
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/openzipkin/zipkin-go v0.1.5 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/prometheus/common v0.0.0-20190107103113-2998b132700a // indirect
github.com/prometheus/procfs v0.0.0-20190104112138-b1a0a9a36d74 // indirect
github.com/sirupsen/logrus v1.3.0
github.com/stretchr/testify v1.3.0 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/sirupsen/logrus v1.4.0
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
golang.org/x/net v0.0.0-20190313220215-9f648a60d977
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect
golang.org/x/tools v0.0.0-20190315165135-f59e586bb35d
google.golang.org/api v0.1.0
google.golang.org/appengine v1.4.0 // indirect
google.golang.org/genproto v0.0.0-20190110221437-6909d8a4a91b
google.golang.org/grpc v1.17.0
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53
golang.org/x/sys v0.0.0-20190318195719-6c81ef8f67ca // indirect
golang.org/x/tools v0.0.0-20190318005222-63e6ed9258fa
google.golang.org/api v0.2.0
google.golang.org/grpc v1.19.0
)
Loading

0 comments on commit 3aad2bc

Please sign in to comment.