| 124 | } |
| 125 | |
| 126 | func setOptions(args *Args) []parser.Option { |
| 127 | var opts []parser.Option |
| 128 | |
| 129 | if args.DBDriver != "" { |
| 130 | opts = append(opts, parser.WithDBDriver(args.DBDriver)) |
| 131 | } |
| 132 | if args.fieldTypes != nil { |
| 133 | opts = append(opts, parser.WithFieldTypes(args.fieldTypes)) |
| 134 | } |
| 135 | |
| 136 | if args.Charset != "" { |
| 137 | opts = append(opts, parser.WithCharset(args.Charset)) |
| 138 | } |
| 139 | if args.Collation != "" { |
| 140 | opts = append(opts, parser.WithCollation(args.Collation)) |
| 141 | } |
| 142 | if args.JSONTag { |
| 143 | opts = append(opts, parser.WithJSONTag(args.JSONNamedType)) |
| 144 | } |
| 145 | if args.TablePrefix != "" { |
| 146 | opts = append(opts, parser.WithTablePrefix(args.TablePrefix)) |
| 147 | } |
| 148 | if args.ColumnPrefix != "" { |
| 149 | opts = append(opts, parser.WithColumnPrefix(args.ColumnPrefix)) |
| 150 | } |
| 151 | if args.NoNullType { |
| 152 | opts = append(opts, parser.WithNoNullType()) |
| 153 | } |
| 154 | if args.IsEmbed { |
| 155 | opts = append(opts, parser.WithEmbed()) |
| 156 | } |
| 157 | if args.IsWebProto { |
| 158 | opts = append(opts, parser.WithWebProto()) |
| 159 | } |
| 160 | |
| 161 | if args.NullStyle != "" { |
| 162 | switch args.NullStyle { |
| 163 | case "sql": |
| 164 | opts = append(opts, parser.WithNullStyle(parser.NullInSql)) |
| 165 | case "ptr": |
| 166 | opts = append(opts, parser.WithNullStyle(parser.NullInPointer)) |
| 167 | default: |
| 168 | fmt.Printf("invalid null style: %s\n", args.NullStyle) |
| 169 | return nil |
| 170 | } |
| 171 | } else { |
| 172 | opts = append(opts, parser.WithNullStyle(parser.NullDisable)) |
| 173 | } |
| 174 | if args.Package != "" { |
| 175 | opts = append(opts, parser.WithPackage(args.Package)) |
| 176 | } |
| 177 | if args.GormType { |
| 178 | opts = append(opts, parser.WithGormType()) |
| 179 | } |
| 180 | if args.ForceTableName { |
| 181 | opts = append(opts, parser.WithForceTableName()) |
| 182 | } |
| 183 | if args.IsExtendedAPI { |