diff --git a/src/main/java/com/crowdin/cli/commands/Actions.java b/src/main/java/com/crowdin/cli/commands/Actions.java index 034483885..2fbe45c73 100644 --- a/src/main/java/com/crowdin/cli/commands/Actions.java +++ b/src/main/java/com/crowdin/cli/commands/Actions.java @@ -27,8 +27,8 @@ NewAction download( boolean ignoreMatch, boolean isVerbose, boolean plainView, boolean userServerSources, boolean keepArchive ); - NewAction generate(FilesInterface files, String token, String baseUrl, String basePath, - String projectId, String source, String translation, Boolean preserveHierarchy, Path destinationPath, boolean skipGenerateDescription); + NewAction init(FilesInterface files, String token, String baseUrl, String basePath, + String projectId, String source, String translation, Boolean preserveHierarchy, Path destinationPath, boolean quiet); NewAction listBranches(boolean noProgress, boolean plainView); 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 b9abf9b6f..c2ec2e19b 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/CliActions.java +++ b/src/main/java/com/crowdin/cli/commands/actions/CliActions.java @@ -33,10 +33,10 @@ public NewAction download( } @Override - public NewAction generate(FilesInterface files, String token, String baseUrl, String basePath, - String projectId, String source, String translation, Boolean preserveHierarchy, Path destinationPath, boolean skipGenerateDescription + public NewAction init(FilesInterface files, String token, String baseUrl, String basePath, + String projectId, String source, String translation, Boolean preserveHierarchy, Path destinationPath, boolean quiet ) { - return new GenerateAction(files, token, baseUrl, basePath, projectId, source, translation, preserveHierarchy, destinationPath, skipGenerateDescription); + return new InitAction(files, token, baseUrl, basePath, projectId, source, translation, preserveHierarchy, destinationPath, quiet); } @Override diff --git a/src/main/java/com/crowdin/cli/commands/actions/GenerateAction.java b/src/main/java/com/crowdin/cli/commands/actions/InitAction.java similarity index 98% rename from src/main/java/com/crowdin/cli/commands/actions/GenerateAction.java rename to src/main/java/com/crowdin/cli/commands/actions/InitAction.java index 44edd8125..176be40c0 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/GenerateAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/InitAction.java @@ -34,7 +34,7 @@ import static java.util.Objects.nonNull; @RequiredArgsConstructor -class GenerateAction implements NewAction { +class InitAction implements NewAction { public static final String BASE_PATH_DEFAULT = "."; public static final String BASE_URL_DEFAULT = "https://api.crowdin.com"; @@ -52,7 +52,7 @@ class GenerateAction implements NewAction { private final String translation; private final Boolean preserveHierarchy; private final Path destinationPath; - private final boolean skipGenerateDescription; + private final boolean quiet; @Override public void act(Outputter out, NoProperties noProperties, NoClient noClient) { @@ -69,7 +69,7 @@ public void act(Outputter out, NoProperties noProperties, NoClient noClient) { } List fileLines = Utils.readResource("/crowdin.yml"); - if (!skipGenerateDescription) { + if (!quiet) { this.updateWithUserInputs(out, asking, fileLines); } files.writeToFile( diff --git a/src/main/java/com/crowdin/cli/commands/picocli/InitSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/InitSubcommand.java index 6b5be46e3..373b14c78 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/InitSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/InitSubcommand.java @@ -18,7 +18,7 @@ ) public class InitSubcommand extends GenericActCommand { - @CommandLine.Option(names = {"-d", "--destination"}, paramLabel = "...", descriptionKey = "crowdin.generate.destination", defaultValue = "crowdin.yml", order = -2) + @CommandLine.Option(names = {"-d", "--destination"}, paramLabel = "...", descriptionKey = "crowdin.init.destination", defaultValue = "crowdin.yml", order = -2) private Path destinationPath; @CommandLine.Option(names = {"-T", "--token"}, paramLabel = "...", descriptionKey = "params.token", order = -2) @@ -43,10 +43,10 @@ public class InitSubcommand extends GenericActCommand { private Boolean preserveHierarchy; @CommandLine.Option(names = "--quiet", descriptionKey = "params.quiet", order = -2) - private boolean skipGenerateDescription; + private boolean quiet; protected NewAction getAction(Actions actions) { - return actions.generate(new FsFiles(), token, baseUrl, basePath, projectId, source, translation, preserveHierarchy, destinationPath, skipGenerateDescription); + return actions.init(new FsFiles(), token, baseUrl, basePath, projectId, source, translation, preserveHierarchy, destinationPath, quiet); } protected NoProperties getProperties(PropertiesBuilders propertiesBuilders, Outputter out) { 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 e8d9dc9ed..f4a387bef 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java @@ -19,7 +19,7 @@ public void testDownload() { @Test public void testGenerate() { - assertNotNull(actions.generate(new FsFiles(), null, null, null, null, null, null, null, null, false)); + assertNotNull(actions.init(new FsFiles(), null, null, null, null, null, null, null, null, false)); } @Test diff --git a/src/test/java/com/crowdin/cli/commands/actions/GenerateActionTest.java b/src/test/java/com/crowdin/cli/commands/actions/InitActionTest.java similarity index 84% rename from src/test/java/com/crowdin/cli/commands/actions/GenerateActionTest.java rename to src/test/java/com/crowdin/cli/commands/actions/InitActionTest.java index b129ea2fa..e22944f03 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/GenerateActionTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/InitActionTest.java @@ -24,7 +24,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; -public class GenerateActionTest { +public class InitActionTest { TempProject project; @@ -46,7 +46,7 @@ public void simpleTest() throws IOException { InputStream responsesIS = setResponses(false, false, "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class)); verify(files).writeToFile(anyString(), any()); @@ -57,7 +57,7 @@ public void simpleTest() throws IOException { public void userInputTest() throws IOException { FilesInterface files = mock(FilesInterface.class); - action = new GenerateAction(files, "token", "", ".", "42", "file.json", "translation.json", true, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, "token", "", ".", "42", "file.json", "translation.json", true, Paths.get(project.getBasePath() + "/crowdin.yml"), false); action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class)); verify(files).writeToFile(anyString(), any()); @@ -68,7 +68,7 @@ public void userInputTest() throws IOException { public void userInputAllTest() throws IOException { FilesInterface files = mock(FilesInterface.class); - action = new GenerateAction(files, "token", "https://api.crowdin.com", ".", "42", "file.json", "translation.json", true, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, "token", "https://api.crowdin.com", ".", "42", "file.json", "translation.json", true, Paths.get(project.getBasePath() + "/crowdin.yml"), false); action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class)); ArgumentCaptor contentCaptor = ArgumentCaptor.forClass(InputStream.class); @@ -95,7 +95,7 @@ public void writeToFileThrowsTest() throws IOException { InputStream responsesIS = setResponses(false, false, "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class))); verify(files).writeToFile(anyString(), any()); @@ -109,7 +109,7 @@ public void enterprisetest() throws IOException { InputStream responsesIS = setResponses(false, true, "undefined", "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class))); verify(files).writeToFile(anyString(), any()); @@ -123,7 +123,7 @@ public void enterpriseUrlTest() throws IOException { InputStream responsesIS = setResponses(false, true, "https://undefined.crowdin.com", "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class))); verify(files).writeToFile(anyString(), any()); @@ -137,7 +137,7 @@ public void enterpriseNoNametest() throws IOException { InputStream responsesIS = setResponses(false, true, "", "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class))); verify(files).writeToFile(anyString(), any()); @@ -152,7 +152,7 @@ public void fileExists() throws IOException { InputStream responsesIS = setResponses(false, true, "https://undefined.crowdin.com", "apiToken", "42", "."); System.setIn(responsesIS); - action = new GenerateAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); + action = new InitAction(files, null, null, null, null, null, null, null, Paths.get(project.getBasePath() + "/crowdin.yml"), false); action.act(Outputter.getDefault(), new NoProperties(), mock(NoClient.class)); verifyNoMoreInteractions(files); diff --git a/src/test/java/com/crowdin/cli/commands/picocli/InitSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/InitSubcommandTest.java index 21d9b4b36..14d8f4fcf 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/InitSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/InitSubcommandTest.java @@ -12,7 +12,7 @@ public class InitSubcommandTest extends PicocliTestUtils { public void testGenerate() { this.execute(CommandNames.INIT); verify(actionsMock) - .generate(any(), any(), any(), any(), any(), any(), any(), any(), any(), anyBoolean()); + .init(any(), any(), any(), any(), any(), any(), any(), any(), any(), anyBoolean()); this.check(false); } } 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 7d43d3a3a..3832ac66a 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java @@ -56,7 +56,7 @@ void mockActions() { when(actionsMock.download(any(), anyBoolean(), any(), any(), anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(actionMock); - when(actionsMock.generate(any(), any(), any(), any(), any(), any(), any(), any(), any(), anyBoolean())) + when(actionsMock.init(any(), any(), any(), any(), any(), any(), any(), any(), any(), anyBoolean())) .thenReturn(actionMock); when(actionsMock.listBranches(anyBoolean(), anyBoolean())) .thenReturn(actionMock);