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

feat: comment add #801

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public NewAction<ProjectProperties, ProjectClient> stringAdd(

@Override
public NewAction<ProjectProperties, ProjectClient> stringComment(boolean plainView, String text, String stringId, String language, String type, String issueType) {
return new StringCommentAction(plainView, text, stringId, language, type, issueType);
return new CommentAddAction(plainView, text, stringId, language, type, issueType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static com.crowdin.cli.utils.console.ExecutionStatus.OK;

@AllArgsConstructor
class StringCommentAction implements NewAction<ProjectProperties, ProjectClient> {
class CommentAddAction implements NewAction<ProjectProperties, ProjectClient> {

private final boolean plainView;
private final String text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@

@CommandLine.Command(
sortOptions = false,
name = CommandNames.STRING_COMMENT
name = CommandNames.ADD
)
class StringCommentSubcommand extends ActCommandProject {
class CommentAddSubcommand extends ActCommandProject {

@CommandLine.Parameters(descriptionKey = "crowdin.string.comment.text")
@CommandLine.Parameters(descriptionKey = "crowdin.comment.add.text")
protected String text;

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

@CommandLine.Option(names = {"-l", "--language"}, paramLabel = "...", descriptionKey = "crowdin.string.comment.language", order = -2)
@CommandLine.Option(names = {"-l", "--language"}, paramLabel = "...", descriptionKey = "crowdin.comment.add.language", order = -2)
protected String languageId;

@CommandLine.Option(names = {"--type"}, paramLabel = "...", descriptionKey = "crowdin.string.comment.type", order = -2)
@CommandLine.Option(names = {"--type"}, paramLabel = "...", descriptionKey = "crowdin.comment.add.type", order = -2)
protected String type;

@CommandLine.Option(names = {"--issue-type"}, paramLabel = "...", descriptionKey = "crowdin.string.comment.issue-type", order = -2)
@CommandLine.Option(names = {"--issue-type"}, paramLabel = "...", descriptionKey = "crowdin.comment.add.issue-type", order = -2)
protected String issueType;

@CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
name = CommandNames.COMMENT,
subcommands = {
CommentListSubcommand.class,
CommentResolveSubcommand.class
CommentResolveSubcommand.class,
CommentAddSubcommand.class
}
)
class CommentSubcommand extends HelpCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
subcommands = {
StringListSubcommand.class,
StringAddSubcommand.class,
StringCommentSubcommand.class,
StringDeleteSubcommand.class,
StringEditSubcommand.class
}
Expand Down
19 changes: 9 additions & 10 deletions src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,6 @@ crowdin.string.add.few=Plural form few (paucal)
crowdin.string.add.many=Plural form many
crowdin.string.add.zero=Plural form zero

# CROWDIN STRING COMMENT COMMAND
crowdin.string.comment.usage.description=Add a comment to the given string
crowdin.string.comment.usage.customSynopsis=@|fg(green) crowdin string comment|@ <text> [CONFIG OPTIONS] [OPTIONS]
crowdin.string.comment.text=String comment text
crowdin.string.comment.string-id=Numeric string identifier
crowdin.string.comment.language=Target language to which the comment belongs
crowdin.string.comment.type=Defines the comment type. Supported types: comment, issue
crowdin.string.comment.issue-type=Defines the issue type. Supported types: general_question, translation_mistake, context_request, source_mistake


# CROWDIN STRING LIST COMMAND
crowdin.string.list.usage.description=Show a list of source strings
crowdin.string.list.usage.customSynopsis=@|fg(green) crowdin string list|@ [CONFIG OPTIONS] [OPTIONS]
Expand Down Expand Up @@ -356,6 +346,15 @@ crowdin.comment.resolve.usage.description=Resolve reported issues with source st
crowdin.comment.resolve.usage.customSynopsis=@|fg(green) crowdin comment resolve|@ <id> [CONFIG OPTIONS] [OPTIONS]
crowdin.comment.resolve.id=Numeric ID of the string comment

# CROWDIN COMMENT ADD COMMAND
crowdin.comment.add.usage.description=Add a comment to the given string
crowdin.comment.add.usage.customSynopsis=@|fg(green) crowdin comment add|@ <text> [CONFIG OPTIONS] [OPTIONS]
crowdin.comment.add.text=String comment text
crowdin.comment.add.string-id=Numeric string identifier
crowdin.comment.add.language=Target language to which the comment belongs
crowdin.comment.add.type=Defines the comment type. Supported types: comment, issue
crowdin.comment.add.issue-type=Defines the issue type. Supported types: general_question, translation_mistake, context_request, source_mistake

# CROWDIN PRE-TRANSLATE
crowdin.pre-translate.usage.description=Pre-translate files via Machine Translation (MT) or Translation Memory (TM)
crowdin.pre-translate.usage.customSynopsis=@|fg(green) crowdin pre-translate|@ [CONFIG OPTIONS] [OPTIONS]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.Mockito.*;

public class StringCommentActionTest {
public class CommentAddActionTest {

NewAction<ProjectProperties, ProjectClient> action;

Expand All @@ -46,7 +46,7 @@ public void testStringComment(String text, String type, String languageId, Strin
setIssueType(request.getIssueType());
setStringId(request.getStringId());
}});
action = new StringCommentAction(true, text, stringId, languageId, type, issueType);
action = new CommentAddAction(true, text, stringId, languageId, type, issueType);
action.act(Outputter.getDefault(), pb, client);
verify(client).commentString(request);
verifyNoMoreInteractions(client);
Expand All @@ -71,7 +71,7 @@ public void testStringCommentThrows() {
when(client.commentString(request))
.thenThrow(new RuntimeException("Whoops"));

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.verify;

public class StringCommentSubcommandTest extends PicocliTestUtils {
public class CommentAddSubcommandTest extends PicocliTestUtils {

@Test
public void testStringComment() {
this.execute(CommandNames.STRING, CommandNames.STRING_COMMENT, "\"My Comment\"", "--string-id", "1",
this.execute(CommandNames.COMMENT, CommandNames.ADD, "\"My Comment\"", "--string-id", "1",
"--language", "en", "--type", "comment");
verify(actionsMock)
.stringComment(anyBoolean(), any(), any(), any(), any(), any());
Expand All @@ -19,7 +19,7 @@ public void testStringComment() {

@Test
public void testStringCommentInvalidOptions() {
this.executeInvalidParams(CommandNames.STRING, CommandNames.STRING_COMMENT, "\"My Comment\"");
this.executeInvalidParams(CommandNames.COMMENT, CommandNames.ADD, "\"My Comment\"");
}

}
1 change: 1 addition & 0 deletions website/blog/2024-05-28-cli-v4/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Tip: Use the [`file list`](/commands/crowdin-file-list) command to get the file
* Moved `id` to parameter. Now only 1 string can be removed at a time.
* Removed the `--text` and `--identifier` options. Only `id` is used as a string identifier.
* Added `--directory` and `--scope` options to the [`string list`](/commands/crowdin-string-list) command.
* `comment` command was moved to [`comment add`](/commands/crowdin-comment-add) command.

```diff
-crowdin string add Download --file main/src/strings.xml --identifier "download"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:includedir: ../generated-picocli-docs
:command: crowdin-string-comment
:command: crowdin-comment-add

== crowdin string comment
== crowdin comment add

include::{includedir}/{command}.adoc[tag=picocli-generated-man-section-description]

Expand Down
2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ const sidebars = {
'commands/crowdin-string-add',
'commands/crowdin-string-edit',
'commands/crowdin-string-delete',
'commands/crowdin-string-comment',
]
},
{
Expand Down Expand Up @@ -216,6 +215,7 @@ const sidebars = {
items: [
'commands/crowdin-comment-list',
'commands/crowdin-comment-resolve',
'commands/crowdin-comment-add',
]
},
{
Expand Down
Loading