From 80ebeacdb2de6bf876f7b85c8ce4f0ee95fab68f Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Wed, 9 Mar 2016 11:55:47 +1000 Subject: [PATCH] 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")); } }