Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "excludeFile" option #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ Then, in your project, add a dependency on the runtime library:

`elm install tiziano88/elm-protobuf`

## Options

Options can be passed to the plugin in the --elm_out value, with the following
syntax:

`protoc "--elm_out=option=value;option=value1,value2:."`

The valid options are:

- `excludeFile`: A list of files that should be ignored. Usefull to ignore a
proto2 file that is a dependency of the compiled file.

## References

https://developers.google.com/protocol-buffers/
Expand Down
20 changes: 20 additions & 0 deletions protoc-gen-elm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ func main() {
inFile.SourceCodeInfo = nil
}

if parameter := req.GetParameter(); parameter != "" {
list := strings.Split(parameter, ";")
for _, item := range list {
splitted := strings.Split(item, "=")
if len(splitted) != 2 {
log.Fatalf("Invalid parameter. Expected 'variable=value', got: '%s'", item)
}
switch splitted[0] {
case "excludeFile":
fileList := strings.Split(splitted[1], ",")
for _, name := range fileList {
excludedFiles[name] = true
}
default:
log.Fatalf("Unknow parameter: %s", splitted[0])

}
}
}

log.Printf("Input data: %v", proto.MarshalTextString(req))

resp := &plugin.CodeGeneratorResponse{}
Expand Down