-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: crowdin file list, remove generate alias (#746)
- Loading branch information
Showing
22 changed files
with
164 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/java/com/crowdin/cli/commands/actions/FileListAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.crowdin.cli.commands.actions; | ||
|
||
import com.crowdin.cli.client.CrowdinProjectFull; | ||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.commands.Outputter; | ||
import com.crowdin.cli.commands.functionality.ProjectFilesUtils; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import com.crowdin.cli.utils.console.ConsoleSpinner; | ||
import com.crowdin.cli.utils.tree.DrawTree; | ||
import com.crowdin.client.sourcefiles.model.Branch; | ||
import com.crowdin.client.sourcefiles.model.File; | ||
import com.crowdin.client.sourcefiles.model.FileInfo; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE; | ||
import static com.crowdin.cli.utils.console.ExecutionStatus.OK; | ||
|
||
class FileListAction implements NewAction<ProjectProperties, ProjectClient> { | ||
|
||
private final boolean noProgress; | ||
private final String branchName; | ||
private final boolean treeView; | ||
private final boolean plainView; | ||
private final boolean isVerbose; | ||
|
||
public FileListAction(boolean noProgress, String branchName, boolean treeView, boolean plainView, boolean isVerbose) { | ||
this.noProgress = noProgress || plainView; | ||
this.branchName = branchName; | ||
this.treeView = treeView; | ||
this.plainView = plainView; | ||
this.isVerbose = isVerbose; | ||
} | ||
|
||
@Override | ||
public void act(Outputter out, ProjectProperties pb, ProjectClient client) { | ||
CrowdinProjectFull project = ConsoleSpinner | ||
.execute(out, "message.spinner.fetching_project_info", "error.collect_project_info", | ||
this.noProgress, this.plainView, () -> client.downloadFullProject(this.branchName)); | ||
|
||
Long branchId = Optional.ofNullable(project.getBranch()).map(Branch::getId).orElse(null); | ||
|
||
List<Map.Entry<String, FileInfo>> list = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFileInfos()) | ||
.entrySet() | ||
.stream() | ||
.filter(entry -> Objects.equals(entry.getValue().getBranchId(), branchId)) | ||
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey().replaceAll("^[/\\\\]+", ""), e.getValue())) | ||
.collect(Collectors.toList()); | ||
|
||
if (treeView) { | ||
List<String> tree = list.stream().map(Map.Entry::getKey).collect(Collectors.toList()); | ||
DrawTree.draw(tree).forEach(out::println); | ||
return; | ||
} | ||
|
||
for (Map.Entry<String, FileInfo> entry : list) { | ||
if (plainView) { | ||
if (isVerbose) { | ||
if (entry.getValue() instanceof File) { | ||
File file = (File) entry.getValue(); | ||
String str = entry.getValue().getId() + | ||
" " + | ||
entry.getKey() + | ||
" " + | ||
file.getType() + | ||
" " + | ||
file.getParserVersion() + | ||
" " + | ||
file.getRevisionId(); | ||
out.println(str); | ||
} else { | ||
out.println(entry.getValue().getId() + " " + entry.getKey() + " " + entry.getValue().getType()); | ||
} | ||
} else { | ||
out.println(entry.getValue().getId() + " " + entry.getKey()); | ||
} | ||
} else { | ||
if (isVerbose) { | ||
if (entry.getValue() instanceof File) { | ||
File file = (File) entry.getValue(); | ||
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file.list_verbose_full"), entry.getValue().getId(), entry.getKey(), entry.getValue().getType(), file.getParserVersion(), file.getRevisionId()))); | ||
} else { | ||
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file.list_verbose"), entry.getValue().getId(), entry.getKey(), entry.getValue().getType()))); | ||
} | ||
} else { | ||
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file.list"), entry.getValue().getId(), entry.getKey()))); | ||
} | ||
} | ||
} | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/main/java/com/crowdin/cli/commands/actions/ListProjectAction.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
src/main/java/com/crowdin/cli/commands/functionality/DryrunProjectFiles.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.