Skip to content

Commit

Permalink
Restored condition to check for number of parameters above expected n…
Browse files Browse the repository at this point in the history
…umber (now 4). Also changed for loop to be more idiomatic.
  • Loading branch information
willchang committed Aug 19, 2022
1 parent bb0c8ee commit 38c90d2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,18 @@ func ParseOptions(req *plugin_go.CodeGeneratorRequest) (*PluginOptions, error) {
}

parts := strings.Split(params, ",")
if len(parts) < 2 {
if len(parts) < 2 || len(parts) > 4 {
return nil, fmt.Errorf("Invalid parameter: %s", params)
}

options.TemplateFile = parts[0]
options.OutputFile = path.Base(parts[1])

// Handle extra options
if len(parts) > 2 {
extraOptions := parts[2:]

for i := 0; i < len(extraOptions); i++ {
for i := range extraOptions {
switch i {
case 0: // Third option
switch extraOptions[i] {
Expand All @@ -194,7 +195,6 @@ func ParseOptions(req *plugin_go.CodeGeneratorRequest) (*PluginOptions, error) {
return nil, fmt.Errorf("Invalid parameter: %s", params)
}
}

}
}

Expand Down

0 comments on commit 38c90d2

Please sign in to comment.