Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: suppress progress output for crowdin file download with --no-progress #880

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/crowdin/cli/commands/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ NewAction<PropertiesWithFiles, ProjectClient> preTranslate(

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

NewAction<ProjectProperties, ProjectClient> fileDownload(String file, String branch, boolean noProgress, String destParam);
yevheniyJ marked this conversation as resolved.
Show resolved Hide resolved

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);

NewAction<ProjectProperties, ProjectClient> projectBrowse();
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/crowdin/cli/commands/actions/CliActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,22 @@ 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);
return new FileDownloadAction(file, branch, false, destParam);
}

@Override
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);
return new FileDownloadTranslationAction(file, languageId, branch, false, destParam);
}

@Override
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,14 @@ class FileDownloadAction implements NewAction<ProjectProperties, ProjectClient>

private final String file;
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(branch));
noProgress, false, () -> client.downloadFullProject(branch));
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
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 +57,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien
out,
"message.spinner.downloading_file",
"error.downloading_file",
false,
noProgress,
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
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);
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
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,
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
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,
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
Loading