Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed May 30, 2023
1 parent bed6816 commit 9d7f29a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void act(Outputter out, ProjectProperties pb, ClientComment client) {
comment.getId(),
commentText,
Objects.toString(comment.getIssueType(), StringUtils.EMPTY),
Objects.toString(comment.getIssueStatus(), StringUtils.EMPTY)
Objects.toString(comment.getIssueStatus(), StringUtils.EMPTY).toLowerCase()
)
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@
import com.crowdin.client.stringcomments.model.AddStringCommentRequest;
import com.crowdin.client.stringcomments.model.StringComment;


import java.util.Objects;

import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE;
import static com.crowdin.cli.utils.console.ExecutionStatus.OK;

class StringCommentAction implements NewAction<ProjectProperties, ProjectClient> {

private boolean plainView;
private final boolean plainView;
private final boolean noProgress;
private final String text;
private final String stringId;
private final String language;
private String type;
private final String type;
private final String issueType;

public StringCommentAction(boolean plainView, boolean noProgress, String text, String stringId, String language,
Expand All @@ -37,7 +34,6 @@ public StringCommentAction(boolean plainView, boolean noProgress, String text, S

@Override
public void act(Outputter out, ProjectProperties pb, ProjectClient client) {
type = Objects.toString(type, "comment");
AddStringCommentRequest request = RequestBuilder.addComment(text, type, language, issueType, stringId);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
import picocli.CommandLine;

@CommandLine.Command(
sortOptions = false,
name = CommandNames.COMMENT_LIST
)
class CommentListSubcommand extends ActCommandComment {

@CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain")
protected boolean plainView;

@CommandLine.Option(names = {"--string-id"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.string-id")
@CommandLine.Option(names = {"--string-id"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.string-id", order = -2)
private String stringId;

@CommandLine.Option(names = {"--type"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.type")
@CommandLine.Option(names = {"--type"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.type", order = -2)
private com.crowdin.client.stringcomments.model.Type type;

@CommandLine.Option(names = {"--issue-type"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.issue-type")
@CommandLine.Option(names = {"--issue-type"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.issue-type", order = -2)
private com.crowdin.client.issues.model.Type issueType;

@CommandLine.Option(names = {"--status"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.status")
@CommandLine.Option(names = {"--status"}, paramLabel = "...", descriptionKey = "crowdin.comment.list.status", order = -2)
private IssueStatus status;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import picocli.CommandLine;

import java.util.ArrayList;
import java.util.Objects;
import java.util.List;

import static com.crowdin.client.stringcomments.model.Type.COMMENT;

@CommandLine.Command(
sortOptions = false,
name = CommandNames.STRING_COMMENT
Expand Down Expand Up @@ -39,6 +42,9 @@ class StringCommentSubcommand extends ActCommandProject {
@Override
protected List<String> checkOptions() {
List<String> errors = new ArrayList<>();

type = Objects.toString(type, COMMENT.toString().toLowerCase());

if (Strings.isEmpty(stringId)) {
errors.add(RESOURCE_BUNDLE.getString("error.comment_string_id_not_specified"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ message.bundle.added=@|green,bold Bundle #%s '%s'|@ @|green added successfully|@
message.comment.list=@|yellow #%d|@ @|bold %s|@
message.comment.list.verbose=@|yellow #%d|@ @|bold %s|@ @|green %s|@ @|bold %s|@
message.comment.list_empty=No comments found
message.comment.resolved=@|green,bold String comment #%s|@ @|green successfully resolved|@
message.comment.added=@|green,bold Comment #%s '%s'|@ @|green added successfully|@
message.comment.resolved=@|green String comment|@ @|yellow #%s|@ @|green successfully resolved|@
message.comment.added=@|green Comment|@ @|yellow #%s|@ @|green,bold '%s'|@ @|green added successfully|@

message.pre_translate.local_files_message=Out of %d files, only %d of them were found locally. Use '--verbose' to list them
message.pre_translate.local_files_message_verbose=Out of %d files, %d of them were found locally:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testStringCommentThrows() {
when(client.commentString(request))
.thenThrow(new RuntimeException("Whoops"));

action = new StringCommentAction(true, true, null, null, null, null, null);
action = new StringCommentAction(true, true, null, null, null, "comment", null);

assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client));

Expand Down

0 comments on commit 9d7f29a

Please sign in to comment.