github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/internal/codegen/plugin_option.go (about) 1 package codegen 2 3 import ( 4 "strings" 5 ) 6 7 /* 8 Creation Time: 2021 - Jul - 29 9 Created by: (ehsan) 10 Maintainers: 11 1. Ehsan N. Moosa (E2) 12 Auditor: Ehsan N. Moosa (E2) 13 Copyright Ronak Software Group 2020 14 */ 15 16 const ( 17 optKeyRony = "rony_opt" 18 optValEdgeDep = "no_edge_dep" 19 optValCrc32 = "crc32" 20 optValConstructorJSONStr = "json_str" 21 optValConstructorJSONInt64 = "json_int64" 22 optOpenAPI = "open_api" 23 optCleanProto = "clean_proto" 24 ) 25 26 type ConstructorFormat string 27 28 const ( 29 StringJSON ConstructorFormat = "str" 30 Int64JSON ConstructorFormat = "int64" 31 ) 32 33 type PluginOptions struct { 34 NoEdgeDependency bool 35 CRC32 bool 36 ConstructorFormat ConstructorFormat 37 OpenAPI bool 38 ExportCleanProto bool 39 } 40 41 func (op *PluginOptions) ParamFunc(key, value string) error { 42 switch key { 43 case optKeyRony: 44 for _, v := range strings.Split(value, "|") { 45 switch strings.TrimSpace(v) { 46 case optValEdgeDep: 47 op.NoEdgeDependency = true 48 case optValCrc32: 49 op.CRC32 = true 50 case optValConstructorJSONStr: 51 op.ConstructorFormat = StringJSON 52 case optValConstructorJSONInt64: 53 op.ConstructorFormat = Int64JSON 54 case optOpenAPI: 55 op.OpenAPI = true 56 case optCleanProto: 57 op.ExportCleanProto = true 58 } 59 } 60 } 61 62 return nil 63 }