Skip to content

Commit

Permalink
Merge pull request #327 from crowdin/add-download-sources
Browse files Browse the repository at this point in the history
Add 'download sources' command and add export options to config file
  • Loading branch information
andrii-bodnar committed Dec 8, 2020
2 parents 2a7d566 + bc05331 commit bf93b0a
Show file tree
Hide file tree
Showing 45 changed files with 1,170 additions and 288 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {

implementation 'info.picocli:picocli:4.5.0'

implementation 'com.github.crowdin:crowdin-api-client-java:1.2.12'
implementation 'com.github.crowdin:crowdin-api-client-java:1.3.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
testImplementation 'org.hamcrest:hamcrest:2.2'
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crowdin.cli.client;

import com.crowdin.client.core.model.PatchRequest;
import com.crowdin.client.labels.model.AddLabelRequest;
import com.crowdin.client.labels.model.Label;
import com.crowdin.client.projectsgroups.model.ProjectSettings;
import com.crowdin.client.sourcefiles.model.AddBranchRequest;
Expand Down Expand Up @@ -186,7 +187,7 @@ public SourceString addSourceString(AddSourceStringRequest request) {
@Override
public List<SourceString> listSourceString(Long fileId, String labelIds, String filter) {
return executeRequestFullList((limit, offset) -> this.client.getSourceStringsApi()
.listSourceStrings(this.projectId, fileId, null, labelIds, filter, limit, offset));
.listSourceStrings(this.projectId, fileId, null, labelIds, filter, null, limit, offset));
}

@Override
Expand Down Expand Up @@ -217,4 +218,18 @@ public List<Label> listLabels() {
return executeRequestFullList((limit, offset) -> this.client.getLabelsApi()
.listLabels(this.projectId, limit, offset));
}

@Override
public Label addLabel(AddLabelRequest request) {
return executeRequest(() -> this.client.getLabelsApi()
.addLabel(this.projectId, request)
.getData());
}

@Override
public URL downloadFile(Long fileId) {
return url(executeRequest(() -> this.client.getSourceFilesApi()
.downloadFile(this.projectId, fileId)
.getData()));
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/crowdin/cli/client/ProjectClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crowdin.cli.client;

import com.crowdin.client.core.model.PatchRequest;
import com.crowdin.client.labels.model.AddLabelRequest;
import com.crowdin.client.labels.model.Label;
import com.crowdin.client.sourcefiles.model.AddBranchRequest;
import com.crowdin.client.sourcefiles.model.AddDirectoryRequest;
Expand Down Expand Up @@ -59,4 +60,8 @@ public interface ProjectClient extends Client {
URL exportProjectTranslation(ExportProjectTranslationRequest request);

List<Label> listLabels();

Label addLabel(AddLabelRequest request);

URL downloadFile(Long fileId);
}
7 changes: 3 additions & 4 deletions src/main/java/com/crowdin/cli/commands/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public interface Actions {

NewAction<PropertiesWithFiles, ProjectClient> download(
FilesInterface files, boolean noProgress, String languageId, boolean pseudo, String branchName,
boolean ignoreMatch, boolean isVerbose, Boolean skipTranslatedOnly,
Boolean skipUntranslatedFiles, Boolean exportApprovedOnly, boolean plainView
boolean ignoreMatch, boolean isVerbose, boolean plainView
);

NewAction<NoProperties, NoClient> generate(FilesInterface files, Path destinationPath, boolean skipGenerateDescription);
Expand Down Expand Up @@ -78,8 +77,8 @@ NewAction<BaseProperties, ClientTm> tmDownload(
String targetLanguageId, boolean noProgress, File to, FilesInterface files);

NewAction<PropertiesWithTargets, ProjectClient> downloadTargets(
List<String> targetNames, FilesInterface files, boolean noProgress, List<String> langIds, boolean isVerbose, Boolean skipTranslatedOnly,
Boolean skipUntranslatedFiles, Boolean exportApprovedOnly, boolean plainView, boolean debug);
List<String> targetNames, FilesInterface files, boolean noProgress,
List<String> langIds, boolean isVerbose, boolean plainView, boolean debug);

NewAction<NoProperties, NoClient> checkNewVersion();

Expand Down
13 changes: 5 additions & 8 deletions src/main/java/com/crowdin/cli/commands/actions/CliActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ public class CliActions implements Actions {
@Override
public NewAction<PropertiesWithFiles, ProjectClient> download(
FilesInterface files, boolean noProgress, String languageId, boolean pseudo, String branchName,
boolean ignoreMatch, boolean isVerbose, Boolean skipTranslatedOnly,
Boolean skipUntranslatedFiles, Boolean exportApprovedOnly, boolean plainView
boolean ignoreMatch, boolean isVerbose, boolean plainView
) {
return new DownloadAction(files, noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose,
skipTranslatedOnly, skipUntranslatedFiles, exportApprovedOnly, plainView);
return new DownloadAction(files, noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose, plainView);
}

@Override
Expand Down Expand Up @@ -158,11 +156,10 @@ public NewAction<NoProperties, NoClient> checkNewVersion() {

@Override
public NewAction<PropertiesWithTargets, ProjectClient> downloadTargets(
List<String> targetNames, FilesInterface files, boolean noProgress, List<String> langIds, boolean isVerbose,
Boolean skipTranslatedOnly, Boolean skipUntranslatedFiles, Boolean exportApprovedOnly, boolean plainView, boolean debug
List<String> targetNames, FilesInterface files, boolean noProgress,
List<String> langIds, boolean isVerbose, boolean plainView, boolean debug
) {
return new DownloadTargetsAction(targetNames, files, noProgress, langIds, isVerbose, skipTranslatedOnly,
skipUntranslatedFiles, exportApprovedOnly, plainView, debug);
return new DownloadTargetsAction(targetNames, files, noProgress, langIds, isVerbose, plainView, debug);
}


Expand Down
Loading

0 comments on commit bf93b0a

Please sign in to comment.