diff --git a/src/main/java/com/crowdin/cli/commands/Actions.java b/src/main/java/com/crowdin/cli/commands/Actions.java index 4a397e92..35272203 100644 --- a/src/main/java/com/crowdin/cli/commands/Actions.java +++ b/src/main/java/com/crowdin/cli/commands/Actions.java @@ -140,9 +140,9 @@ NewAction preTranslate( NewAction fileUploadTranslation(File file, String branch, String dest, String languageId, boolean plainView); - NewAction fileDownload(String file, String branch, String destParam); + NewAction fileDownload(String file, String branch, boolean noProgress, String destParam); - NewAction fileDownloadTranslation(String file, String languageId, String branch, String destParam); + NewAction fileDownloadTranslation(String file, String languageId, String branch, boolean noProgress, String destParam); NewAction fileDelete(String file, String branch); diff --git a/src/main/java/com/crowdin/cli/commands/actions/CliActions.java b/src/main/java/com/crowdin/cli/commands/actions/CliActions.java index c964abe1..1c01c3d9 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/CliActions.java +++ b/src/main/java/com/crowdin/cli/commands/actions/CliActions.java @@ -299,13 +299,13 @@ public NewAction fileUploadTranslation(File fi } @Override - public NewAction fileDownload(String file, String branch, String destParam) { - return new FileDownloadAction(file, branch, destParam); + public NewAction fileDownload(String file, String branch, boolean noProgress, String destParam) { + return new FileDownloadAction(file, branch, noProgress, destParam); } @Override - public NewAction fileDownloadTranslation(String file, String languageId, String branch, String destParam) { - return new FileDownloadTranslationAction(file, languageId, branch, destParam); + public NewAction fileDownloadTranslation(String file, String languageId, String branch, boolean noProgress, String destParam) { + return new FileDownloadTranslationAction(file, languageId, branch, noProgress, destParam); } @Override diff --git a/src/main/java/com/crowdin/cli/commands/actions/FileDownloadAction.java b/src/main/java/com/crowdin/cli/commands/actions/FileDownloadAction.java index 34bc6a15..5dfd129f 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/FileDownloadAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/FileDownloadAction.java @@ -29,13 +29,21 @@ class FileDownloadAction implements NewAction 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"))); @@ -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()); diff --git a/src/main/java/com/crowdin/cli/commands/actions/FileDownloadTranslationAction.java b/src/main/java/com/crowdin/cli/commands/actions/FileDownloadTranslationAction.java index b42bf07a..36f760e8 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/FileDownloadTranslationAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/FileDownloadTranslationAction.java @@ -36,13 +36,14 @@ public class FileDownloadTranslationAction implements NewAction client.buildProjectFileTranslation(sourceFileInfo.getId(), request) ); @@ -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(); diff --git a/src/main/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommand.java index 911f57ba..9378eeff 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommand.java @@ -31,7 +31,7 @@ class FileDownloadSubcommand extends ActCommandProject { @Override protected NewAction 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); } } diff --git a/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java b/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java index b0eff092..bc3fe8c2 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java @@ -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 diff --git a/src/test/java/com/crowdin/cli/commands/actions/FileDownloadActionTest.java b/src/test/java/com/crowdin/cli/commands/actions/FileDownloadActionTest.java index 723a1c4f..06b03595 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/FileDownloadActionTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/FileDownloadActionTest.java @@ -54,7 +54,7 @@ public void testDownload() { when(client.downloadFile(eq(101L))) .thenReturn(urlMock); - NewAction action = new FileDownloadAction("first.po", null, "dest"); + NewAction action = new FileDownloadAction("first.po", null, false, "dest"); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(any()); @@ -75,7 +75,7 @@ public void testDownload_StringBasedProject() { when(client.downloadFullProject(any())) .thenReturn(build); - NewAction action = new FileDownloadAction("first.po", "main", "dest"); + NewAction action = new FileDownloadAction("first.po", "main", false, "dest"); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(any()); diff --git a/src/test/java/com/crowdin/cli/commands/actions/FileDownloadTranslationActionTest.java b/src/test/java/com/crowdin/cli/commands/actions/FileDownloadTranslationActionTest.java index 7b3220ff..b0642bbf 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/FileDownloadTranslationActionTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/FileDownloadTranslationActionTest.java @@ -58,7 +58,7 @@ public void testDownloadTranslation() { when(client.buildProjectFileTranslation(eq(101L), eq(request))) .thenReturn(urlMock); - NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, null); + NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, false, null); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -86,7 +86,7 @@ public void testDownloadTranslationWithDest() { when(client.buildProjectFileTranslation(eq(101L), eq(request))) .thenReturn(urlMock); - NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, "path/to/save"); + NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, false, "path/to/save"); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -108,7 +108,7 @@ public void testDownloadTranslation_StringBasedProject() { when(client.downloadFullProject()) .thenReturn(build); - NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, "path/to/save"); + NewAction action = new FileDownloadTranslationAction("first.po", "ua", null, false, "path/to/save"); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -137,7 +137,7 @@ public void testDownloadTranslation_AllLanguages() { when(client.buildProjectFileTranslation(eq(101L), any())) .thenReturn(urlMock); - NewAction action = new FileDownloadTranslationAction("first.po", "all", null, null); + NewAction action = new FileDownloadTranslationAction("first.po", "all", null, false, null); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); diff --git a/src/test/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommandTest.java index 368c1141..f058fd9a 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/FileDownloadSubcommandTest.java @@ -10,14 +10,14 @@ 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(), 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(), false, any()); this.check(true); } diff --git a/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java b/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java index 2ba108eb..b34c2583 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java @@ -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);