diff --git a/plugin.go b/plugin.go index 45b047a..89416fc 100644 --- a/plugin.go +++ b/plugin.go @@ -163,38 +163,35 @@ 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]) - if len(parts) > 2 { - extraOptions := parts[2:] - - for i := 0; i < len(extraOptions); i++ { - switch i { - case 0: // Third option - switch extraOptions[i] { - case "source_relative": - options.SourceRelative = true - case "default": - options.SourceRelative = false - default: - return nil, fmt.Errorf("Invalid parameter: %s", params) - } - case 1: // Fourth option - switch extraOptions[i] { - case "separate_files": - options.SeparateFiles = true - case "default": - options.SeparateFiles = false - default: - return nil, fmt.Errorf("Invalid parameter: %s", params) - } + extraOptions := parts[2:] + + for i := range extraOptions { + switch i { + case 0: // Third option + switch extraOptions[i] { + case "source_relative": + options.SourceRelative = true + case "default": + options.SourceRelative = false + default: + return nil, fmt.Errorf("Invalid parameter: %s", params) + } + case 1: // Fourth option + switch extraOptions[i] { + case "separate_files": + options.SeparateFiles = true + case "default": + options.SeparateFiles = false + default: + return nil, fmt.Errorf("Invalid parameter: %s", params) } - } }