|
15 | 15 | import picocli.CommandLine.Option; |
16 | 16 |
|
17 | 17 | import java.nio.file.Path; |
| 18 | +import java.util.ArrayList; |
18 | 19 | import java.util.List; |
| 20 | +import java.util.Objects; |
19 | 21 |
|
20 | 22 |
|
21 | 23 | @Command( |
@@ -164,20 +166,27 @@ public void upload( |
164 | 166 | configuration.setCustomerId(customerId); |
165 | 167 | } |
166 | 168 |
|
167 | | - if (Boolean.TRUE.equals(overwrite)) |
| 169 | + List<String> effectiveUploadOptions = new ArrayList<>(); |
| 170 | + List<String> configurationUploadOptions = configuration.getUploadOptions(); |
| 171 | + if (configurationUploadOptions != null) |
168 | 172 | { |
169 | | - uploadOptions.add("REPLACE_TRANSLATION_IF_FOUND"); |
| 173 | + effectiveUploadOptions = new ArrayList<>(configurationUploadOptions); |
| 174 | + } |
| 175 | + if (uploadOptions != null) |
| 176 | + { |
| 177 | + effectiveUploadOptions = new ArrayList<>(uploadOptions); |
170 | 178 | } |
171 | 179 |
|
172 | | - if (Boolean.TRUE.equals(delete)) |
| 180 | + if (Boolean.TRUE.equals(overwrite)) |
173 | 181 | { |
174 | | - uploadOptions.add("DELETE_NOT_PRESENT_KEYS"); |
| 182 | + effectiveUploadOptions.add("REPLACE_TRANSLATION_IF_FOUND"); |
175 | 183 | } |
176 | 184 |
|
177 | | - if (uploadOptions != null) |
| 185 | + if (Boolean.TRUE.equals(delete)) |
178 | 186 | { |
179 | | - configuration.setUploadOptions(uploadOptions); |
| 187 | + effectiveUploadOptions.add("DELETE_NOT_PRESENT_KEYS"); |
180 | 188 | } |
| 189 | + configuration.setUploadOptions(effectiveUploadOptions); |
181 | 190 |
|
182 | 191 | if (Boolean.TRUE.equals(dryRun)) |
183 | 192 | { |
@@ -239,10 +248,7 @@ public void download( |
239 | 248 | { |
240 | 249 | configuration.setCustomerId(customerId); |
241 | 250 | } |
242 | | - if (downloadOptions != null) |
243 | | - { |
244 | | - configuration.setDownloadOptions(downloadOptions); |
245 | | - } |
| 251 | + configuration.setDownloadOptions(Objects.requireNonNullElseGet(downloadOptions, ArrayList::new)); |
246 | 252 | ConfigurationValidator configurationValidator = new ConfigurationValidator(); |
247 | 253 | configurationValidator.validateDownloadConfiguration(configuration); |
248 | 254 | SimpleLocalizeClient client = SimpleLocalizeClient.create(configuration.getBaseUrl(), configuration.getApiKey()); |
@@ -290,7 +296,7 @@ public void pull( |
290 | 296 | configuration.setPullPath(pullPath); |
291 | 297 | } |
292 | 298 |
|
293 | | - if(StringUtils.isNotEmpty(filterRegex)) |
| 299 | + if (StringUtils.isNotEmpty(filterRegex)) |
294 | 300 | { |
295 | 301 | configuration.setFilterRegex(filterRegex); |
296 | 302 | } |
|
0 commit comments