Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into arg-based-creds
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Jan 15, 2025
2 parents 238cf23 + 5331d62 commit fd5b34c
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/crowdin/cli/commands/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ NewAction<PropertiesWithFiles, ProjectClient> preTranslate(

NewAction<ProjectProperties, ProjectClient> fileUploadTranslation(File file, String branch, String dest, String languageId, boolean plainView);

NewAction<ProjectProperties, ProjectClient> fileDownload(String file, String branch, String destParam);
NewAction<ProjectProperties, ProjectClient> fileDownload(String file, String branch, boolean noProgress, String destParam);

NewAction<ProjectProperties, ProjectClient> fileDownloadTranslation(String file, String languageId, String branch, String destParam);
NewAction<ProjectProperties, ProjectClient> fileDownloadTranslation(String file, String languageId, String branch, boolean noProgress, String destParam);

NewAction<ProjectProperties, ProjectClient> fileDelete(String file, String branch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ public NewAction<ProjectProperties, ProjectClient> fileUploadTranslation(File fi
}

@Override
public NewAction<ProjectProperties, ProjectClient> fileDownload(String file, String branch, String destParam) {
return new FileDownloadAction(file, branch, destParam);
public NewAction<ProjectProperties, ProjectClient> fileDownload(String file, String branch, boolean noProgress, String destParam) {
return new FileDownloadAction(file, branch, noProgress, destParam);
}

@Override
public NewAction<ProjectProperties, ProjectClient> fileDownloadTranslation(String file, String languageId, String branch, String destParam) {
return new FileDownloadTranslationAction(file, languageId, branch, destParam);
public NewAction<ProjectProperties, ProjectClient> fileDownloadTranslation(String file, String languageId, String branch, boolean noProgress, String destParam) {
return new FileDownloadTranslationAction(file, languageId, branch, noProgress, destParam);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ class FileDownloadAction implements NewAction<ProjectProperties, ProjectClient>

private final String file;
private final String branch;
private final boolean noProgress;
private final String dest;

public FileDownloadAction(String file, String branch, String dest) {
this.file = file;
this.branch = branch;
this.noProgress = false;
this.dest = dest;
}

@Override
public void act(Outputter out, ProjectProperties properties, ProjectClient client) {
CrowdinProjectFull project = ConsoleSpinner
.execute(out, "message.spinner.fetching_project_info", "error.collect_project_info",
false, false, () -> client.downloadFullProject(branch));
noProgress, false, () -> client.downloadFullProject(branch));
boolean isStringsBasedProject = Objects.equals(project.getType(), Type.STRINGS_BASED);
if (isStringsBasedProject) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.no_file_string_project")));
Expand All @@ -56,7 +64,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
out,
"message.spinner.downloading_file",
"error.downloading_file",
false,
noProgress,
false,
() -> {
URL url = client.downloadFile(foundFile.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ public class FileDownloadTranslationAction implements NewAction<ProjectPropertie
private final String file;
private final String languageId;
private final String branch;
private final boolean noProgress;
private final String dest;

@Override
public void act(Outputter out, ProjectProperties properties, ProjectClient client) {
CrowdinProjectFull project = ConsoleSpinner
.execute(out, "message.spinner.fetching_project_info", "error.collect_project_info",
false, false, client::downloadFullProject);
noProgress, false, client::downloadFullProject);
boolean isStringsBasedProject = Objects.equals(project.getType(), Type.STRINGS_BASED);
if (isStringsBasedProject) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.no_file_string_project")));
Expand Down Expand Up @@ -82,7 +83,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
out,
"message.spinner.building_translation",
"error.building_translation",
false,
noProgress,
false,
() -> client.buildProjectFileTranslation(sourceFileInfo.getId(), request)
);
Expand All @@ -99,7 +100,7 @@ private void saveToFile(String destPath, URL url, Outputter out) {
out,
"message.spinner.downloading_translation",
"error.write_file",
false,
noProgress,
false,
() -> {
FilesInterface files = new FsFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FileDownloadSubcommand extends ActCommandProject {
@Override
protected NewAction<ProjectProperties, ProjectClient> getAction(Actions actions) {
if (Objects.nonNull(languageId))
return actions.fileDownloadTranslation(file, languageId, branch, destination);
return actions.fileDownload(file, branch, destination);
return actions.fileDownloadTranslation(file, languageId, branch, noProgress, destination);
return actions.fileDownload(file, branch, noProgress, destination);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ params.translation=Path to the translation files
params.dest=Specify file name in Crowdin
params.preserve-hierarchy=Choose whether to save the directory hierarchy in the Crowdin project
params.quiet=Do not ask for interactive input prompts
params.skipUntranslatedStrings=Skip untranslated strings in exported files (does not work with .docx, .html, .md and other document files)
params.skipUntranslatedStrings=Skip untranslated strings in exported files (does not work with .docx, .html, .md and other document files). For more details see https://support.crowdin.com/project-settings/export/#skip-untranslated-strings
params.skipUntranslatedFiles=Omit downloading not fully translated files
params.keepArchive=Do not remove the downloaded archive with translations after it's extracting
params.exportOnlyApproved=Include approved translations only in exported files. If not combined with --skip-untranslated-strings option, strings without approval are fulfilled with the source language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ void testFileUploadTranslation() {

@Test
void testFileDownload() {
assertNotNull(actions.fileDownload(null, null, null));
assertNotNull(actions.fileDownload(null, null, false, null));
}

@Test
void testFileDownloadTranslation() {
assertNotNull(actions.fileDownloadTranslation(null, null,null, null));
assertNotNull(actions.fileDownloadTranslation(null, null,null, false, null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void testDownload() {
when(client.downloadFile(eq(101L)))
.thenReturn(urlMock);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadAction("first.po", null, "dest");
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadAction("first.po", null, false, "dest");
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject(any());
Expand All @@ -75,7 +75,7 @@ public void testDownload_StringBasedProject() {
when(client.downloadFullProject(any()))
.thenReturn(build);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadAction("first.po", "main", "dest");
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadAction("first.po", "main", false, "dest");
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject(any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testDownloadTranslation() {
when(client.buildProjectFileTranslation(eq(101L), eq(request)))
.thenReturn(urlMock);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, null);
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, false, null);
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testDownloadTranslationWithDest() {
when(client.buildProjectFileTranslation(eq(101L), eq(request)))
.thenReturn(urlMock);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, "path/to/save");
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, false, "path/to/save");
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand All @@ -108,7 +108,7 @@ public void testDownloadTranslation_StringBasedProject() {
when(client.downloadFullProject())
.thenReturn(build);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, "path/to/save");
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "ua", null, false, "path/to/save");
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand Down Expand Up @@ -137,7 +137,7 @@ public void testDownloadTranslation_AllLanguages() {
when(client.buildProjectFileTranslation(eq(101L), any()))
.thenReturn(urlMock);

NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "all", null, null);
NewAction<ProjectProperties, ProjectClient> action = new FileDownloadTranslationAction("first.po", "all", null, false, null);
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
import org.junit.jupiter.api.Test;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;

class FileDownloadSubcommandTest extends PicocliTestUtils {

@Test
public void testFileDownload() {
this.execute(CommandNames.FILE, CommandNames.FILE_DOWNLOAD, "file.txt");
verify(actionsMock).fileDownload(any(), any(), any());
verify(actionsMock).fileDownload(any(), any(), eq(false), any());
this.check(true);
}

@Test
public void testFileDownloadTranslations() {
this.execute(CommandNames.FILE, CommandNames.FILE_DOWNLOAD, "file.txt", "--language", "uk");
verify(actionsMock).fileDownloadTranslation(any(), any(), any(), any());
verify(actionsMock).fileDownloadTranslation(any(), any(), any(), eq(false), any());
this.check(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ void mockActions() {
.thenReturn(actionMock);
when(actionsMock.fileUploadTranslation(any(), any(), any(), any(), anyBoolean()))
.thenReturn(actionMock);
when(actionsMock.fileDownload(any(), any(), any()))
when(actionsMock.fileDownload(any(), any(), anyBoolean(), any()))
.thenReturn(actionMock);
when(actionsMock.fileDownloadTranslation(any(), any(), any(), any()))
when(actionsMock.fileDownloadTranslation(any(), any(), any(), anyBoolean(), any()))
.thenReturn(actionMock);
when(actionsMock.fileDelete(any(), any()))
.thenReturn(actionMock);
Expand Down
2 changes: 1 addition & 1 deletion website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Crowdin CLI can be installed as a stand-alone Java application. [Download](https
- Click Start
- In the *Start Search* box, type `cmd`, and then press `Ctrl`+`Shift`+`Enter`
- If the *User Account Control* dialog box appears, confirm that the action it displays is what you want, and then click _Continue_
- Run `setup-crowdin.bat` script in order to add crowdin command to the Command Prompt
- Run `setup_crowdin.bat` script in order to add crowdin command to the Command Prompt
- Restart your Command Prompt

## Nix package manager
Expand Down

0 comments on commit fd5b34c

Please sign in to comment.