Skip to content

Commit 2dd6c35

Browse files
committed
Add support for --tags in upload & download
1 parent 68e2931 commit 2dd6c35

File tree

10 files changed

+53
-5
lines changed

10 files changed

+53
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.simplelocalize</groupId>
66
<artifactId>simplelocalize-cli</artifactId>
7-
<version>2.9.0</version>
7+
<version>2.10.0</version>
88
<packaging>jar</packaging>
99
<name>simplelocalize-cli</name>
1010
<description>Official SimpleLocalize Command Line Interface</description>

reflect-config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"java.lang.String",
1616
"java.lang.String",
1717
"java.util.List",
18+
"java.util.List",
1819
"java.lang.String",
1920
"java.lang.String",
2021
"java.lang.String",
@@ -48,6 +49,7 @@
4849
"java.lang.String",
4950
"java.lang.String",
5051
"java.util.List",
52+
"java.util.List",
5153
"java.lang.String",
5254
"java.lang.String",
5355
"java.lang.String",

src/main/java/io/simplelocalize/cli/SimplelocalizeCliCommand.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public void upload(
9191
@Option(names = {"--uploadPath", "--path"}, description = "Path to file with translation or translation keys to upload. Use '{lang}' to define language key if you are uploading more than one file with translations.") String uploadPath,
9292
@Option(names = {"--uploadFormat", "--format"}, description = "Translations file format") String uploadFormat,
9393
@Option(names = {"--uploadOptions", "--options"}, split = ",", description = "(Optional) Upload options") List<String> uploadOptions,
94+
@Option(names = {"--uploadTags", "--tags"}, split = ",", description = "(Optional) Assign tags to translation keys") List<String> tags,
9495
@Option(names = {"--uploadNamespace", "--namespace"}, description = "(Optional) Specify namespace for single file upload (cannot be used with {ns} in uploadPath)") String namespace,
9596
@Option(names = {"--uploadLanguageKey", "--languageKey"}, description = "(Optional) Specify language key for single file upload (cannot be used with {lang} in uploadPath)") String languageKey,
9697
@Option(names = {"--uploadCustomerId", "--customerId"}, description = "(Optional) Assign customerId to uploaded translations") String customerId,
@@ -140,6 +141,11 @@ public void upload(
140141
configuration.setUploadNamespace(namespace);
141142
}
142143

144+
if (tags != null && !tags.isEmpty())
145+
{
146+
configuration.setUploadTags(tags);
147+
}
148+
143149
List<String> effectiveUploadOptions = new ArrayList<>();
144150
List<String> configurationUploadOptions = configuration.getUploadOptions();
145151
if (configurationUploadOptions != null)
@@ -190,6 +196,7 @@ public void download(
190196
@Option(names = {"--downloadPath", "--path"}, description = "Directory where translations should be downloaded") String downloadPath,
191197
@Option(names = {"--downloadFormat", "--format"}, description = "Translations file format") String downloadFormat,
192198
@Option(names = {"--downloadOptions", "--options"}, split = ",", description = "(Optional) Download options, use comma separated values for multiple options") List<String> downloadOptions,
199+
@Option(names = {"--downloadTags", "--tags"}, split = ",", description = "(Optional) Download translation keys with given tags") List<String> tags,
193200
@Option(names = {"--downloadSort", "--sort"}, description = "(Optional) Download sorting") String downloadSort,
194201
@Option(names = {"--downloadLanguageKey", "--languageKey"}, split = ",", description = "(Optional) Download translations only for given language key, use comma separated values for multiple keys") List<String> languageKeys,
195202
@Option(names = {"--downloadCustomerId", "--customerId"}, description = "(Optional) Download translations only for given customerId") String customerId,
@@ -242,6 +249,11 @@ public void download(
242249
configuration.setDownloadSort(downloadSort);
243250
}
244251

252+
if (tags != null && !tags.isEmpty())
253+
{
254+
configuration.setDownloadTags(tags);
255+
}
256+
245257
List<String> nonNullConfigurationFileDownloadOptions = Objects.requireNonNullElse(configuration.getDownloadOptions(), List.of());
246258
configuration.setDownloadOptions(nonNullConfigurationFileDownloadOptions);
247259
boolean hasArgumentDownloadOptions = downloadOptions != null && !downloadOptions.isEmpty();

src/main/java/io/simplelocalize/cli/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Version
44
{
55

6-
public static final String NUMBER = "2.9.0";
6+
public static final String NUMBER = "2.10.0";
77

88
private Version()
99
{

src/main/java/io/simplelocalize/cli/client/SimpleLocalizeUriFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ URI buildDownloadUri(ExportRequest exportRequest)
3333
endpointUrl += "&downloadOptions=" + String.join(",", downloadOptions);
3434
}
3535

36+
List<String> tags = exportRequest.tags();
37+
if (!tags.isEmpty())
38+
{
39+
endpointUrl += "&tags=" + String.join(",", tags);
40+
}
41+
3642
String namespace = exportRequest.namespace();
3743
if (StringUtils.isNotEmpty(namespace))
3844
{
@@ -76,6 +82,12 @@ URI buildUploadUri(UploadRequest uploadRequest, boolean isPreviewMode)
7682
endpointUrl += "&uploadOptions=" + String.join(",", uploadOptions);
7783
}
7884

85+
List<String> tags = uploadRequest.tags();
86+
if (!tags.isEmpty())
87+
{
88+
endpointUrl += "&tags=" + String.join(",", tags);
89+
}
90+
7991
String namespace = uploadRequest.namespace();
8092
if (StringUtils.isNotEmpty(namespace))
8193
{

src/main/java/io/simplelocalize/cli/client/dto/ExportRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public record ExportRequest(
1111
String customerId,
1212
String namespace,
1313
List<String> options,
14-
String sort
14+
String sort,
15+
List<String> tags
1516
)
1617
{
1718
}

src/main/java/io/simplelocalize/cli/client/dto/UploadRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public record UploadRequest(
1313
List<String> options,
1414
String namespace,
1515
String customerId,
16-
String translationKey
16+
String translationKey,
17+
List<String> tags
1718
)
1819
{
1920
}

src/main/java/io/simplelocalize/cli/client/dto/proxy/Configuration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class Configuration
5252
@Builder.Default
5353
private List<String> uploadOptions = new ArrayList<>();
5454

55+
@Builder.Default
56+
private List<String> uploadTags = new ArrayList<>();
57+
5558
@Builder.Default
5659
private Boolean dryRun = false;
5760

@@ -68,6 +71,9 @@ public class Configuration
6871
@Builder.Default
6972
private List<String> downloadOptions = new ArrayList<>();
7073

74+
@Builder.Default
75+
private List<String> downloadTags = new ArrayList<>();
76+
7177
@Builder.Default
7278
private List<String> downloadLanguageKeys = new ArrayList<>();
7379

src/main/java/io/simplelocalize/cli/command/DownloadCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ public void invoke() throws IOException, InterruptedException
4141
final List<String> languageKeys = configuration.getDownloadLanguageKeys();
4242
if (!languageKeys.isEmpty())
4343
{
44-
log.info("Language(s): {}", languageKeys);
44+
log.info("Languages: {}", languageKeys);
45+
}
46+
47+
final List<String> tags = configuration.getDownloadTags();
48+
if (!tags.isEmpty())
49+
{
50+
log.info("Tags: {}", tags);
4551
}
4652

4753
final String sort = configuration.getDownloadSort();
@@ -90,6 +96,7 @@ public void invoke() throws IOException, InterruptedException
9096
.withCustomerId(customerId)
9197
.withOptions(downloadOptions)
9298
.withSort(sort)
99+
.withTags(tags)
93100
.build();
94101
final List<DownloadableFile> downloadableFiles = client.exportFiles(exportRequest);
95102
for (DownloadableFile downloadableFile : downloadableFiles)

src/main/java/io/simplelocalize/cli/command/UploadCommand.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public void invoke() throws IOException, InterruptedException
6363
log.info("Language: {}", uploadLanguageKey);
6464
}
6565

66+
final List<String> uploadTags = configuration.getUploadTags();
67+
if (!uploadTags.isEmpty())
68+
{
69+
log.info("Tags: {}", uploadTags);
70+
}
71+
6672
final String uploadNamespace = configuration.getUploadNamespace();
6773
final boolean hasDefinedNamespace = StringUtils.isNotBlank(uploadNamespace);
6874
if (hasDefinedNamespace)
@@ -120,6 +126,7 @@ public void invoke() throws IOException, InterruptedException
120126
.withNamespace(effectiveNamespace)
121127
.withCustomerId(uploadCustomerId)
122128
.withOptions(uploadOptions)
129+
.withTags(uploadTags)
123130
.build();
124131

125132
String logMessage = "";

0 commit comments

Comments
 (0)