setOption sets a number of options on the environment. returns an error if any of them fail.
(args []string)
| 1127 | // setOption sets a number of options on the environment. returns an error if |
| 1128 | // any of them fail. |
| 1129 | func (e *Evaluator) setOption(args []string) error { |
| 1130 | var issues []string |
| 1131 | for idx := 0; idx < len(args); { |
| 1132 | arg := args[idx] |
| 1133 | idx++ |
| 1134 | switch arg { |
| 1135 | case "--container": |
| 1136 | err := e.loadContainerOption(idx, args) |
| 1137 | idx++ |
| 1138 | if err != nil { |
| 1139 | issues = append(issues, fmt.Sprintf("container: %v", err)) |
| 1140 | } |
| 1141 | case "--extension": |
| 1142 | err := e.loadExtensionOption(idx, args) |
| 1143 | idx++ |
| 1144 | if err != nil { |
| 1145 | issues = append(issues, fmt.Sprintf("extension: %v", err)) |
| 1146 | } |
| 1147 | case "--enable_escaped_fields": |
| 1148 | err := e.AddSerializableOption(&backtickOpt{enabled: true}) |
| 1149 | if err != nil { |
| 1150 | issues = append(issues, fmt.Sprintf("enable_escaped_fields: %v", err)) |
| 1151 | } |
| 1152 | case "--enable_json_field_names": |
| 1153 | err := e.AddSerializableOption(&jsonOpt{enabled: true}) |
| 1154 | if err != nil { |
| 1155 | issues = append(issues, fmt.Sprintf("enable_json_field_names: %v", err)) |
| 1156 | } |
| 1157 | case "--enable_partial_eval": |
| 1158 | err := e.EnablePartialEval() |
| 1159 | if err != nil { |
| 1160 | issues = append(issues, fmt.Sprintf("enable_partial_eval: %v", err)) |
| 1161 | } |
| 1162 | default: |
| 1163 | issues = append(issues, fmt.Sprintf("unsupported option '%s'", arg)) |
| 1164 | } |
| 1165 | } |
| 1166 | if len(issues) > 0 { |
| 1167 | return errors.New(strings.Join(issues, "\n")) |
| 1168 | } |
| 1169 | return nil |
| 1170 | } |
| 1171 | |
| 1172 | func checkOptionArgs(idx int, args []string) error { |
| 1173 | if idx >= len(args) { |
no test coverage detected