From 8e01b61627bb44a580672e9fdd3d20ae53f83789 Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Wed, 24 Feb 2016 14:04:48 +1000 Subject: [PATCH 1/2] ZNTA-930 - zanata init can handle file type project --- .../commands/init/SourceConfigPrompt.java | 143 ++++++++++++++++-- .../commands/init/TransConfigPrompt.java | 79 ++++++++-- .../client/commands/push/PushOptionsImpl.java | 2 +- .../client/commands/push/RawPushCommand.java | 5 +- .../src/main/resources/prompts.properties | 2 + .../commands/init/SourceConfigPromptTest.java | 75 ++++++--- .../commands/init/TransConfigPromptTest.java | 25 +++ 7 files changed, 282 insertions(+), 49 deletions(-) diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java index 8e65671e..eae66530 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Map; import java.util.Set; import org.kohsuke.args4j.Option; @@ -36,13 +38,23 @@ import org.zanata.client.commands.push.PushCommand; import org.zanata.client.commands.push.PushOptions; import org.zanata.client.commands.push.PushOptionsImpl; +import org.zanata.client.commands.push.RawPushCommand; +import org.zanata.client.commands.push.RawPushStrategy; +import org.zanata.common.DocumentType; +import org.zanata.rest.client.FileResourceClient; import org.zanata.rest.client.RestClientFactory; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Hint; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning; import static org.zanata.client.commands.StringUtil.indent; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl.*; +import static org.zanata.common.ProjectType.File; import static org.zanata.client.commands.Messages.get; /** @@ -60,13 +72,15 @@ class SourceConfigPrompt { private final ConsoleInteractor console; private final ConfigurableProjectOptions opts; private final PushOptions pushOptions; + private final SrcDocsFinder + srcDocsFinder; // includes and excludes in ConfigurableProjectOptions do not have symmetric // setter/getter (set method accepts String but get method returns // ImmutableList) therefore we have to keep instance variables here private String includes; private String excludes; - private PushCommand pushCommand; private Set docNames; + private List rawDocumentTypes; public SourceConfigPrompt( ConsoleInteractor console, @@ -83,13 +97,7 @@ public SourceConfigPrompt( pushOptions.setKey(opts.getKey()); pushOptions.setLocaleMapList(opts.getLocaleMapList()); - RestClientFactory clientFactory = - OptionsUtil.createClientFactoryWithoutVersionCheck(pushOptions); - pushCommand = - new PushCommand(pushOptions, - clientFactory.getCopyTransClient(), - clientFactory.getAsyncProcessClient(), - clientFactory); + srcDocsFinder = makeSrcDocFinder(); } SourceConfigPrompt promptUser() throws Exception { @@ -117,6 +125,24 @@ SourceConfigPrompt promptUser() throws Exception { pushOptions.setSrcDir(srcDir); pushOptions.setIncludes(includes); pushOptions.setExcludes(excludes); + + + // if project type is file, we need to ask file type in order to find source documents + if (File.name().equalsIgnoreCase(pushOptions.getProjectType())) { + + console.blankLine(); + console.printfln(Question, get("project.file.type.question")); + RestClientFactory clientFactory = getClientFactory(pushOptions); + FileResourceClient client = + clientFactory.getFileResourceClient(); + rawDocumentTypes = client.acceptedFileTypes(); + // this answer is not persisted in zanata.xml so user will still need to type it when they do the actual push + console.printfln(Hint, PushOptionsImpl.fileTypeHelp); + console.printf(Question, get("file.type.prompt")); + String answer = console.expectAnyNotBlankAnswer(); + ((PushOptionsImpl) pushOptions).setFileTypes(answer); + } + console.blankLine(); docNames = findDocNames(); if (docNames.isEmpty()) { @@ -140,13 +166,14 @@ SourceConfigPrompt promptUser() throws Exception { return this; } + @VisibleForTesting + protected RestClientFactory getClientFactory(PushOptions pushOptions) { + return OptionsUtil + .createClientFactoryWithoutVersionCheck(pushOptions); + } + private Set findDocNames() throws IOException { - AbstractPushStrategy strategy = pushCommand.getStrategy(pushOptions); - return strategy.findDocNames(pushOptions.getSrcDir(), - pushOptions.getIncludes(), pushOptions.getExcludes(), - pushOptions.getDefaultExcludes(), - pushOptions.getCaseSensitive(), - pushOptions.getExcludeLocaleFilenames()); + return srcDocsFinder.findSrcDocNames(); } private void hintAdvancedConfigurations() { @@ -191,4 +218,92 @@ public String getExcludes() { public Set getDocNames() { return docNames; } + + private SrcDocsFinder makeSrcDocFinder() { + String projectType = pushOptions.getProjectType(); + if (projectType.equalsIgnoreCase(File.name())) { + return new RawSrcDocsFinder(pushOptions); + } else { + return new OtherSrcDocsFinder(pushOptions); + } + } + + interface SrcDocsFinder { + Set findSrcDocNames(); + } + + class RawSrcDocsFinder implements SrcDocsFinder { + + private final RawPushStrategy strategy; + + RawSrcDocsFinder(PushOptions pushOptions) { + strategy = new RawPushStrategy(); + strategy.setPushOptions(pushOptions); + } + + @Override + public Set findSrcDocNames() { + PushOptions opts = strategy.getOpts(); + ImmutableList extensions = filteredFileExtensions(opts); + return ImmutableSet.copyOf(strategy.getSrcFiles( + opts.getSrcDir(), opts.getIncludes(), + opts.getExcludes(), extensions, + opts.getDefaultExcludes(), + opts.getCaseSensitive())); + } + + private ImmutableList filteredFileExtensions(PushOptions opts) { + // mostly duplicated in RawPushCommand + RestClientFactory clientFactory = getClientFactory(opts); + RawPushCommand rawPushCommand = + new RawPushCommand(opts, clientFactory, console); + Map> filteredDocTypes = + rawPushCommand.validateFileTypes(rawDocumentTypes, + opts.getFileTypes()); + + if (filteredDocTypes.isEmpty()) { + log.info("no valid types specified; nothing to do"); + return ImmutableList.of(); + } + + ImmutableList.Builder sourceFileExtensionsBuilder = + ImmutableList.builder(); + for (Set filteredSourceExtensions : filteredDocTypes + .values()) { + sourceFileExtensionsBuilder.addAll(filteredSourceExtensions); + } + return sourceFileExtensionsBuilder.build(); + } + } + + class OtherSrcDocsFinder implements SrcDocsFinder { + private final AbstractPushStrategy strategy; + private PushOptions opts; + + OtherSrcDocsFinder(PushOptions pushOptions) { + opts = pushOptions; + RestClientFactory clientFactory = getClientFactory(pushOptions); + PushCommand pushCommand = + new PushCommand(pushOptions, + clientFactory.getCopyTransClient(), + clientFactory.getAsyncProcessClient(), + clientFactory); + strategy = pushCommand.getStrategy(pushOptions); + } + + @Override + public Set findSrcDocNames() { + try { + return strategy + .findDocNames(opts.getSrcDir(), opts.getIncludes(), + opts.getExcludes(), + opts.getDefaultExcludes(), + opts.getCaseSensitive(), + opts.getExcludeLocaleFilenames()); + } catch (IOException e) { + throw Throwables.propagate(e); + } + } + } } + diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java index ac32b48d..f38c96a5 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java @@ -23,16 +23,20 @@ import java.io.File; import java.util.Set; +import org.apache.commons.io.FilenameUtils; import org.zanata.client.commands.ConfigurableProjectOptions; import org.zanata.client.commands.ConsoleInteractor; import org.zanata.client.commands.OptionsUtil; -import org.zanata.client.commands.pull.PullCommand; +import org.zanata.client.commands.QualifiedSrcDocName; +import org.zanata.client.commands.TransFileResolver; +import org.zanata.client.commands.UnqualifiedSrcDocName; +import org.zanata.client.commands.pull.PullOptions; import org.zanata.client.commands.pull.PullOptionsImpl; -import org.zanata.client.commands.pull.PullStrategy; import org.zanata.client.config.LocaleList; import org.zanata.client.config.LocaleMapping; -import org.zanata.rest.client.RestClientFactory; +import org.zanata.common.ProjectType; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -55,7 +59,8 @@ class TransConfigPrompt { private final ConfigurableProjectOptions opts; private final Set srcFilesSample; private final PullOptionsImpl pullOptions; - private final PullCommand pullCommand; + private final TransFilePathFinder + transFilePathFinder; private int remainingFileNumber; public TransConfigPrompt(ConsoleInteractor console, @@ -74,10 +79,7 @@ public TransConfigPrompt(ConsoleInteractor console, pullOptions.setProjectType(opts.getProjectType()); pullOptions.setLocaleMapList(opts.getLocaleMapList()); - RestClientFactory clientFactory = - OptionsUtil.createClientFactoryWithoutVersionCheck(opts); - pullCommand = new PullCommand(pullOptions, - clientFactory); + transFilePathFinder = makeTransFilePathFinder(pullOptions); } TransConfigPrompt promptUser() throws Exception { @@ -86,12 +88,11 @@ TransConfigPrompt promptUser() throws Exception { File transDir = new File(localTransDir); pullOptions.setTransDir(transDir); - final PullStrategy strategy = pullCommand.createStrategy(pullOptions); LocaleList localeMapList = pullOptions.getLocaleMapList(); LocaleMapping localeMapping = getSampleLocaleMapping(localeMapList); Iterable transFiles = Iterables.transform(srcFilesSample, - new ToTransFileNameFunction(strategy, localeMapping)); + new ToTransFileNameFunction(transFilePathFinder, localeMapping)); console.printfln(Hint, get("trans.doc.preview"), localeMapping.getLocale()); for (String transFile : transFiles) { console.printfln("%s%s", indent(8), transFile); @@ -110,6 +111,14 @@ TransConfigPrompt promptUser() throws Exception { return this; } + private TransFilePathFinder makeTransFilePathFinder(PullOptions opts) { + if (ProjectType.File.name().equalsIgnoreCase(opts.getProjectType())) { + return new RawTransFilePathFinder(opts); + } else { + return new OtherTransFilePathFinder(opts); + } + } + private static LocaleMapping getSampleLocaleMapping(LocaleList localeMapList) { LocaleMapping localeMapping; @@ -123,19 +132,61 @@ TransConfigPrompt promptUser() throws Exception { private static class ToTransFileNameFunction implements Function { - private final PullStrategy strategy; + private final TransFilePathFinder transFilePathFinder; private final LocaleMapping localeMapping; - public ToTransFileNameFunction(PullStrategy strategy, + public ToTransFileNameFunction(TransFilePathFinder transFilePathFinder, LocaleMapping localeMapping) { - this.strategy = strategy; + this.transFilePathFinder = transFilePathFinder; this.localeMapping = localeMapping; } @Override public String apply(String input) { - return strategy.getTransFileToWrite(input, localeMapping).getPath(); + return transFilePathFinder.getTransFileToWrite(input, localeMapping); + + } + } + + interface TransFilePathFinder { + String getTransFileToWrite(String srcDoc, LocaleMapping localeMapping); + } + + static class RawTransFilePathFinder implements TransFilePathFinder { + private final TransFileResolver transFileResolver; + + RawTransFilePathFinder(PullOptions opts) { + transFileResolver = new TransFileResolver(opts); + } + @Override + public String getTransFileToWrite(String srcDoc, + LocaleMapping localeMapping) { + String targetFileExt = FilenameUtils + .getExtension(srcDoc); + + Optional translationFileExtension = + Optional.fromNullable(targetFileExt); + File file = transFileResolver.resolveTransFile( + QualifiedSrcDocName.from(srcDoc), + localeMapping, translationFileExtension); + return file.getPath(); + } + } + + static class OtherTransFilePathFinder implements TransFilePathFinder { + private final TransFileResolver transFileResolver; + + OtherTransFilePathFinder(PullOptions opts) { + this.transFileResolver = new TransFileResolver(opts); + } + + @Override + public String getTransFileToWrite(String srcDoc, + LocaleMapping localeMapping) { + File transFile = transFileResolver.getTransFile( + UnqualifiedSrcDocName.from(srcDoc), localeMapping); + return transFile.getPath(); } } } diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java index 485beb3f..7e4580b6 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java @@ -189,7 +189,7 @@ public ImmutableList getFileTypes() { return fileTypes; } - private static final String fileTypeHelp = "File types to locate and transmit to the server. \n" + + public static final String fileTypeHelp = "File types to locate and transmit to the server. \n" + "Default file extension will be used unless it is being specified. \n" + "Pattern: TYPE[extension;extension],TYPE[extension] \n" + "Supported types: \n" + diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/RawPushCommand.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/RawPushCommand.java index 5540cc77..971da529 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/RawPushCommand.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/RawPushCommand.java @@ -103,8 +103,7 @@ public RawPushCommand(PushOptions opts, RestClientFactory clientFactory) { consoleInteractor = new ConsoleInteractorImpl(opts); } - @VisibleForTesting - protected RawPushCommand(PushOptions opts, RestClientFactory clientFactory, + public RawPushCommand(PushOptions opts, RestClientFactory clientFactory, ConsoleInteractor console) { super(opts, clientFactory); client = getClientFactory().getFileResourceClient(); @@ -188,7 +187,7 @@ private void validateInputFileType(String inputFileType, * @param acceptedTypes * @param inputFileTypes */ - private Map> validateFileTypes( + public Map> validateFileTypes( List acceptedTypes, List inputFileTypes) { Map> filteredFileTypes = new HashMap<>(); diff --git a/zanata-client-commands/src/main/resources/prompts.properties b/zanata-client-commands/src/main/resources/prompts.properties index 59283e73..eed06604 100644 --- a/zanata-client-commands/src/main/resources/prompts.properties +++ b/zanata-client-commands/src/main/resources/prompts.properties @@ -43,6 +43,8 @@ includes.prompt=Includes (leave blank if not applicable): excludes.question=Do you want to define any Excludes? excludes.usage= - Wildcard pattern to exclude files and directories. Defined it as "configuration.properties,build.properties". excludes.prompt=Excludes (leave blank if not applicable): +project.file.type.question=What file types do you want to use? +file.type.prompt=Please enter file types in comma separated format (e.g. XML_DOCUMENT_TYPE_DEFINITION,IDML[txt]): no.source.doc.found=No source documents found. found.source.docs=Found source documents: source.doc.confirm.yes.no=Continue with these source document settings (y/n)? diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java index 14c6159e..b4430b01 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java @@ -1,6 +1,7 @@ package org.zanata.client.commands.init; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.when; import java.io.File; import java.net.URI; @@ -10,41 +11,40 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.zanata.client.commands.ConfigurableProjectOptions; import org.zanata.client.commands.ConfigurableProjectOptionsImpl; import org.zanata.client.commands.ConsoleInteractor; import org.zanata.client.commands.MockConsoleInteractor; import org.zanata.client.commands.ZanataCommand; +import org.zanata.client.commands.push.PushOptions; +import org.zanata.client.commands.push.PushOptionsImpl; import org.zanata.client.config.LocaleList; +import org.zanata.common.DocumentType; +import org.zanata.rest.client.FileResourceClient; +import org.zanata.rest.client.RestClientFactory; +import com.google.common.collect.ImmutableList; public class SourceConfigPromptTest { @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); private SourceConfigPrompt prompt; - private ConfigurableProjectOptions opts; + private PushOptions opts; + @Mock + private RestClientFactory clientFactory; + @Mock + private FileResourceClient fileClient; @Before public void setUp() throws Exception { - opts = new ConfigurableProjectOptionsImpl() { - @Override - public ZanataCommand initCommand() { - return null; - } - - @Override - public String getCommandName() { - return "testCommand"; - } - - @Override - public String getCommandDescription() { - return "test command"; - } - }; + MockitoAnnotations.initMocks(this); + opts = new PushOptionsImpl(); opts.setUrl(new URI("http://localhost:1234").toURL()); opts.setUsername("admin"); opts.setKey("abc"); prompt = null; + when(clientFactory.getFileResourceClient()).thenReturn(fileClient); } @Test @@ -109,4 +109,45 @@ public void allowUserToRetry() throws Exception { Matchers.contains("*.*")); assertThat(opts.getExcludes(), Matchers.contains("a.pot")); } + + @Test + public void canHandleFileProjectType() throws Exception { + when(fileClient.acceptedFileTypes()).thenReturn(ImmutableList.copyOf(DocumentType.values())); + // here we use absolute path because we create temp files in there + String expectedSrcDir = tempFolder.getRoot().getAbsolutePath() + "/resources"; + ConsoleInteractor console = + MockConsoleInteractor.predefineAnswers( + expectedSrcDir, "messages.txt", + "*Excluded.txt", "PLAIN_TEXT[txt]", "y"); + opts.setProj("fileProject"); + opts.setProjectVersion("master"); + opts.setProjectType("file"); + opts.setLocaleMapList(new LocaleList()); + File folder = tempFolder.newFolder("resources"); + + assertThat(new File(folder, "messages.txt").createNewFile(), + Matchers.is(true)); + assertThat( + new File(folder, "shouldBeExcluded.txt").createNewFile(), + Matchers.is(true)); + + prompt = new SourceConfigPrompt(console, opts) { + @Override + protected RestClientFactory getClientFactory(PushOptions pushOptions) { + return clientFactory; + } + }; + + prompt = prompt.promptUser(); + + assertThat(opts.getSrcDir(), + Matchers.equalTo(new File(expectedSrcDir))); + + assertThat(prompt.getIncludes(), + Matchers.equalTo("messages.txt")); + assertThat(prompt.getExcludes(), Matchers.equalTo("*Excluded.txt")); + assertThat(opts.getIncludes(), + Matchers.contains("messages.txt")); + assertThat(opts.getExcludes(), Matchers.contains("*Excluded.txt")); + } } diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/TransConfigPromptTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/TransConfigPromptTest.java index b1128abb..de65326c 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/TransConfigPromptTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/TransConfigPromptTest.java @@ -109,4 +109,29 @@ public void allowUserToRetry() throws Exception { assertThat(opts.getTransDir(), Matchers.equalTo(new File("po"))); } + + @Test + public void canHandleFileTypeProjectAndDisplayTransFiles() throws Exception { + ConsoleInteractor console = + MockConsoleInteractor.predefineAnswers(".", "y"); + opts.setProjectType("file"); + opts.setProj("about-fedora"); + opts.setProjectVersion("master"); + // provides locale list + LocaleList locales = new LocaleList(); + locales.add(new LocaleMapping("de")); + opts.setLocaleMapList(locales); + prompt = + new TransConfigPrompt(console, opts, Sets.newHashSet("a.txt", + "b.txt")); + + prompt = prompt.promptUser(); + + assertThat(opts.getTransDir(), Matchers.equalTo(new File("."))); + List capturedPrompts = + MockConsoleInteractor.getCapturedPrompts(console); + assertThat(capturedPrompts, Matchers.hasItems( + " ./de/a.txt", + " ./de/b.txt")); + } } From 9ef55064b1f55ec23632168977093cd99776e5d6 Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Wed, 9 Mar 2016 11:55:47 +1000 Subject: [PATCH 2/2] ZNTA-930 - refactor and minor improvements --- .../client/commands/init/SourceConfigPrompt.java | 9 ++++----- .../zanata/client/commands/push/PushOptionsImpl.java | 2 +- .../src/main/resources/prompts.properties | 2 +- .../client/commands/init/SourceConfigPromptTest.java | 10 +++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java index eae66530..b063fa83 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java @@ -80,7 +80,6 @@ class SourceConfigPrompt { private String includes; private String excludes; private Set docNames; - private List rawDocumentTypes; public SourceConfigPrompt( ConsoleInteractor console, @@ -132,10 +131,7 @@ SourceConfigPrompt promptUser() throws Exception { console.blankLine(); console.printfln(Question, get("project.file.type.question")); - RestClientFactory clientFactory = getClientFactory(pushOptions); - FileResourceClient client = - clientFactory.getFileResourceClient(); - rawDocumentTypes = client.acceptedFileTypes(); + // this answer is not persisted in zanata.xml so user will still need to type it when they do the actual push console.printfln(Hint, PushOptionsImpl.fileTypeHelp); console.printf(Question, get("file.type.prompt")); @@ -257,6 +253,9 @@ private ImmutableList filteredFileExtensions(PushOptions opts) { RestClientFactory clientFactory = getClientFactory(opts); RawPushCommand rawPushCommand = new RawPushCommand(opts, clientFactory, console); + FileResourceClient client = + clientFactory.getFileResourceClient(); + List rawDocumentTypes = client.acceptedFileTypes(); Map> filteredDocTypes = rawPushCommand.validateFileTypes(rawDocumentTypes, opts.getFileTypes()); diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java index 7e4580b6..bc0a0b20 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/push/PushOptionsImpl.java @@ -206,7 +206,7 @@ public ImmutableList getFileTypes() { "\t PROPERTIES[properties] \n" + "\t PROPERTIES_UTF8[properties] \n" + "\t XLIFF[xml] \n" + - "Usage --file-types \"XML_DOCUMENT_TYPE_DEFINITION,IDML[txt]\""; + "Usage --file-types \"XML_DOCUMENT_TYPE_DEFINITION,PLAIN_TEXT[md;txt]\""; @Option(name = "--file-types", metaVar = "TYPES", usage = fileTypeHelp) diff --git a/zanata-client-commands/src/main/resources/prompts.properties b/zanata-client-commands/src/main/resources/prompts.properties index eed06604..7ce94ff0 100644 --- a/zanata-client-commands/src/main/resources/prompts.properties +++ b/zanata-client-commands/src/main/resources/prompts.properties @@ -44,7 +44,7 @@ excludes.question=Do you want to define any Excludes? excludes.usage= - Wildcard pattern to exclude files and directories. Defined it as "configuration.properties,build.properties". excludes.prompt=Excludes (leave blank if not applicable): project.file.type.question=What file types do you want to use? -file.type.prompt=Please enter file types in comma separated format (e.g. XML_DOCUMENT_TYPE_DEFINITION,IDML[txt]): +file.type.prompt=Please enter file types in comma separated format (e.g. XML_DOCUMENT_TYPE_DEFINITION,PLAIN_TEXT[md;txt]): no.source.doc.found=No source documents found. found.source.docs=Found source documents: source.doc.confirm.yes.no=Continue with these source document settings (y/n)? diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java index b4430b01..48bf9b17 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/SourceConfigPromptTest.java @@ -117,15 +117,15 @@ public void canHandleFileProjectType() throws Exception { String expectedSrcDir = tempFolder.getRoot().getAbsolutePath() + "/resources"; ConsoleInteractor console = MockConsoleInteractor.predefineAnswers( - expectedSrcDir, "messages.txt", - "*Excluded.txt", "PLAIN_TEXT[txt]", "y"); + expectedSrcDir, "messages.md", + "*Excluded.txt", "PLAIN_TEXT[md;txt]", "y"); opts.setProj("fileProject"); opts.setProjectVersion("master"); opts.setProjectType("file"); opts.setLocaleMapList(new LocaleList()); File folder = tempFolder.newFolder("resources"); - assertThat(new File(folder, "messages.txt").createNewFile(), + assertThat(new File(folder, "messages.md").createNewFile(), Matchers.is(true)); assertThat( new File(folder, "shouldBeExcluded.txt").createNewFile(), @@ -144,10 +144,10 @@ protected RestClientFactory getClientFactory(PushOptions pushOptions) { Matchers.equalTo(new File(expectedSrcDir))); assertThat(prompt.getIncludes(), - Matchers.equalTo("messages.txt")); + Matchers.equalTo("messages.md")); assertThat(prompt.getExcludes(), Matchers.equalTo("*Excluded.txt")); assertThat(opts.getIncludes(), - Matchers.contains("messages.txt")); + Matchers.contains("messages.md")); assertThat(opts.getExcludes(), Matchers.contains("*Excluded.txt")); } }