You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by sg...@apache.org on 2020/08/12 20:14:00 UTC
[freemarker-generator] branch FREEMARKER-153 updated:
FREEMARKER-153 Renamed `--basedir` command line option to `--template-dir`
This is an automated email from the ASF dual-hosted git repository.
sgoeschl pushed a commit to branch FREEMARKER-153
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git
The following commit(s) were added to refs/heads/FREEMARKER-153 by this push:
new 4286f12 FREEMARKER-153 Renamed `--basedir` command line option to `--template-dir`
4286f12 is described below
commit 4286f12d5d1259ecc8f8404591eb664db5efba5e
Author: Siegfried Goeschl <si...@gmail.com>
AuthorDate: Wed Aug 12 22:13:45 2020 +0200
FREEMARKER-153 Renamed `--basedir` command line option to `--template-dir`
---
freemarker-generator-cli/CHANGELOG.md | 3 +
freemarker-generator-cli/README.md | 63 ++++++++--------
.../org/apache/freemarker/generator/cli/Main.java | 12 ++--
.../markdown/cli/introduction/getting-started.md | 83 +++++++++++-----------
.../freemarker/generator/cli/AbstractMainTest.java | 2 +-
.../generator/cli/TemplateLoadingTest.java | 4 +-
6 files changed, 88 insertions(+), 79 deletions(-)
diff --git a/freemarker-generator-cli/CHANGELOG.md b/freemarker-generator-cli/CHANGELOG.md
index 7dcf604..2b17700 100644
--- a/freemarker-generator-cli/CHANGELOG.md
+++ b/freemarker-generator-cli/CHANGELOG.md
@@ -17,6 +17,9 @@ All notable changes to this project will be documented in this file. We try to a
* [FREEMARKER-129] Migrate `freemarker-cli` into `freemarker-generator` project (see [https://github.com/sgoeschl/freemarker-cli](https://github.com/sgoeschl/freemarker-cli))
### Changed
+* [FREEMARKER-153] Packaged templates are now prefixed with `freemarker-generator`, e.g. `freemarker-generator/info.ftl`
+* [FREEMARKER-153] Renamed `--basedir` command line option to `--template-dir`
+* [FREEMARKER-153] Renamed `freemarker-cli` to `freemarker-generator`
* Removing `DataSources.first` and use `dataSources.get(0)` instead
* [FREEMARKER-146] Cleanly separate example templates and data from user-supplied content
* `DataSource` use `uri` instead of `location`
diff --git a/freemarker-generator-cli/README.md b/freemarker-generator-cli/README.md
index 047aa60..373b9e4 100644
--- a/freemarker-generator-cli/README.md
+++ b/freemarker-generator-cli/README.md
@@ -10,46 +10,49 @@ Now you can have a look at the command line options
```text
freemarker-generator -h
-Usage: freemarker-generator (-t=<templates> [-t=<templates>]... |
- -i=<interactiveTemplate>) [-hV] [--stdin] [-b=<baseDir>]
- [--config=<configFile>]
- [--data-source-exclude=<dataSourceExcludePattern>]
- [--data-source-include=<dataSourceIncludePattern>]
- [-e=<inputEncoding>] [-l=<locale>]
- [--output-encoding=<outputEncoding>] [--times=<times>]
- [-D=<String=String>]... [-m=<dataModels>]...
- [-o=<outputs>]... [-P=<String=String>]...
- [-s=<dataSources>]... [<sources>...]
-Apache FreeMarker Generator
- [<sources>...] data source files and/or directories
- -b, --basedir=<baseDir> additional template base directory
- --config=<configFile> FreeMarker Generator configuration file
- -D, --system-property=<String=String>
+UUsage: freemarker-generator (-t=<templates> [-t=<templates>]... |
+ -i=<interactiveTemplate>) [-hV] [--stdin]
+ [--config=<configFile>]
+ [--data-source-exclude=<dataSourceExcludePattern>]
+ [--data-source-include=<dataSourceIncludePattern>]
+ [-e=<inputEncoding>] [-l=<locale>]
+ [--output-encoding=<outputEncoding>]
+ [--template-dir=<templateDir>] [--times=<times>]
+ [-D=<String=String>]... [-m=<dataModels>]...
+ [-o=<outputs>]... [-P=<String=String>]...
+ [-s=<dataSources>]... [<sources>...]
+ Apache FreeMarker Generator
+ [<sources>...] data source files and/or directories
+ --config=<configFile>
+ FreeMarker Generator configuration file
+ -D, --system-property=<String=String>
set system property
- --data-source-exclude=<dataSourceExcludePattern>
+ --data-source-exclude=<dataSourceExcludePattern>
file exclude pattern for data sources
- --data-source-include=<dataSourceIncludePattern>
+ --data-source-include=<dataSourceIncludePattern>
file include pattern for data sources
- -e, --input-encoding=<inputEncoding>
+ -e, --input-encoding=<inputEncoding>
encoding of data source
- -h, --help Show this help message and exit.
- -i, --interactive=<interactiveTemplate>
+ -h, --help Show this help message and exit.
+ -i, --interactive=<interactiveTemplate>
interactive template to process
- -l, --locale=<locale> locale being used for the output, e.g. 'en_US'
- -m, --data-model=<dataModels>
+ -l, --locale=<locale> locale being used for the output, e.g. 'en_US'
+ -m, --data-model=<dataModels>
data model used for rendering
- -o, --output=<outputs> output files or directories
- --output-encoding=<outputEncoding>
+ -o, --output=<outputs> output files or directories
+ --output-encoding=<outputEncoding>
encoding of output, e.g. UTF-8
- -P, --param=<String=String>
+ -P, --param=<String=String>
set parameter
- -s, --data-source=<dataSources>
+ -s, --data-source=<dataSources>
data source used for rendering
- --stdin read data source from stdin
- -t, --template=<templates>
+ --stdin read data source from stdin
+ -t, --template=<templates>
templates to process
- --times=<times> re-run X times for profiling
- -V, --version Print version information and exit.
+ --template-dir=<templateDir>
+ additional template directory
+ --times=<times> re-run X times for profiling
+ -V, --version Print version information and exit.
```
Check the version of the `Apache FreeMarker Generator`
diff --git a/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/Main.java b/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
index 1452ff4..f87cd35 100644
--- a/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
+++ b/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
@@ -66,9 +66,6 @@ public class Main implements Callable<Integer> {
public String interactiveTemplate;
}
- @Option(names = { "-b", "--basedir" }, description = "additional template base directory")
- String baseDir;
-
@Option(names = { "-D", "--system-property" }, description = "set system property")
Properties systemProperties;
@@ -105,6 +102,9 @@ public class Main implements Callable<Integer> {
@Option(names = { "--stdin" }, description = "read data source from stdin")
boolean readFromStdin;
+ @Option(names = { "--template-dir" }, description = "additional template directory")
+ String templateDir;
+
@Option(names = { "--times" }, defaultValue = "1", description = "re-run X times for profiling")
int times;
@@ -167,7 +167,7 @@ public class Main implements Callable<Integer> {
updateSystemProperties();
final Properties configuration = loadFreeMarkerCliConfiguration(configFile);
- final List<File> templateDirectories = getTemplateDirectories(baseDir);
+ final List<File> templateDirectories = getTemplateDirectories(templateDir);
final Settings settings = settings(configuration, templateDirectories);
try {
@@ -258,8 +258,8 @@ public class Main implements Callable<Integer> {
.collect(Collectors.toList());
}
- private static List<File> getTemplateDirectories(String baseDir) {
- return templateDirectorySupplier(baseDir).get();
+ private static List<File> getTemplateDirectories(String additionalTemplateDir) {
+ return templateDirectorySupplier(additionalTemplateDir).get();
}
private static Properties loadFreeMarkerCliConfiguration(String fileName) {
diff --git a/freemarker-generator-cli/src/site/markdown/cli/introduction/getting-started.md b/freemarker-generator-cli/src/site/markdown/cli/introduction/getting-started.md
index 035b492..74deace 100644
--- a/freemarker-generator-cli/src/site/markdown/cli/introduction/getting-started.md
+++ b/freemarker-generator-cli/src/site/markdown/cli/introduction/getting-started.md
@@ -36,46 +36,49 @@ version=0.1.0-SNAPSHOT, time=2020-06-25T21:48:02+0200, commit=b320d00094be878908
```
> freemarker-generator -h
- Usage: freemarker-generator (-t=<templates> [-t=<templates>]... |
- -i=<interactiveTemplate>) [-hV] [--stdin] [-b=<baseDir>]
- [--config=<configFile>]
- [--data-source-exclude=<dataSourceExcludePattern>]
- [--data-source-include=<dataSourceIncludePattern>]
- [-e=<inputEncoding>] [-l=<locale>]
- [--output-encoding=<outputEncoding>] [--times=<times>]
- [-D=<String=String>]... [-m=<dataModels>]...
- [-o=<outputs>]... [-P=<String=String>]...
- [-s=<dataSources>]... [<sources>...]
- Apache FreeMarker Generator
- [<sources>...] data source files and/or directories
- -b, --basedir=<baseDir> additional template base directory
- --config=<configFile> FreeMarker Generator configuration file
- -D, --system-property=<String=String>
- set system property
- --data-source-exclude=<dataSourceExcludePattern>
- file exclude pattern for data sources
- --data-source-include=<dataSourceIncludePattern>
- file include pattern for data sources
- -e, --input-encoding=<inputEncoding>
- encoding of data source
- -h, --help Show this help message and exit.
- -i, --interactive=<interactiveTemplate>
- interactive template to process
- -l, --locale=<locale> locale being used for the output, e.g. 'en_US'
- -m, --data-model=<dataModels>
- data model used for rendering
- -o, --output=<outputs> output files or directories
- --output-encoding=<outputEncoding>
- encoding of output, e.g. UTF-8
- -P, --param=<String=String>
- set parameter
- -s, --data-source=<dataSources>
- data source used for rendering
- --stdin read data source from stdin
- -t, --template=<templates>
- templates to process
- --times=<times> re-run X times for profiling
- -V, --version Print version information and exit.
+Usage: freemarker-generator (-t=<templates> [-t=<templates>]... |
+ -i=<interactiveTemplate>) [-hV] [--stdin]
+ [--config=<configFile>]
+ [--data-source-exclude=<dataSourceExcludePattern>]
+ [--data-source-include=<dataSourceIncludePattern>]
+ [-e=<inputEncoding>] [-l=<locale>]
+ [--output-encoding=<outputEncoding>]
+ [--template-dir=<templateDir>] [--times=<times>]
+ [-D=<String=String>]... [-m=<dataModels>]...
+ [-o=<outputs>]... [-P=<String=String>]...
+ [-s=<dataSources>]... [<sources>...]
+Apache FreeMarker Generator
+ [<sources>...] data source files and/or directories
+ --config=<configFile>
+ FreeMarker Generator configuration file
+ -D, --system-property=<String=String>
+ set system property
+ --data-source-exclude=<dataSourceExcludePattern>
+ file exclude pattern for data sources
+ --data-source-include=<dataSourceIncludePattern>
+ file include pattern for data sources
+ -e, --input-encoding=<inputEncoding>
+ encoding of data source
+ -h, --help Show this help message and exit.
+ -i, --interactive=<interactiveTemplate>
+ interactive template to process
+ -l, --locale=<locale> locale being used for the output, e.g. 'en_US'
+ -m, --data-model=<dataModels>
+ data model used for rendering
+ -o, --output=<outputs> output files or directories
+ --output-encoding=<outputEncoding>
+ encoding of output, e.g. UTF-8
+ -P, --param=<String=String>
+ set parameter
+ -s, --data-source=<dataSources>
+ data source used for rendering
+ --stdin read data source from stdin
+ -t, --template=<templates>
+ templates to process
+ --template-dir=<templateDir>
+ additional template directory
+ --times=<times> re-run X times for profiling
+ -V, --version Print version information and exit.
```
### The Info Template
diff --git a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/AbstractMainTest.java b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/AbstractMainTest.java
index 0d69f5f..909a653 100644
--- a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/AbstractMainTest.java
+++ b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/AbstractMainTest.java
@@ -43,6 +43,6 @@ abstract class AbstractMainTest {
}
private String buildFinalCommandLine(String commandLine) {
- return String.format("--config %s --basedir %s %s", TEST_CONFIG_FILE, TEST_TEMPLATES_DIRECTORY, commandLine);
+ return String.format("--config %s --template-dir %s %s", TEST_CONFIG_FILE, TEST_TEMPLATES_DIRECTORY, commandLine);
}
}
diff --git a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/TemplateLoadingTest.java b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/TemplateLoadingTest.java
index c1f862c..8244d43 100644
--- a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/TemplateLoadingTest.java
+++ b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/TemplateLoadingTest.java
@@ -47,14 +47,14 @@ public class TemplateLoadingTest extends AbstractMainTest {
@Test
public void shouldLoadTemplateFromTemplateLoader() {
- final String[] args = new String[] { "--basedir", TEST_TEMPLATES_DIRECTORY, "-t", ANY_TEMPLATE_NAME };
+ final String[] args = new String[] { "--template-dir", TEST_TEMPLATES_DIRECTORY, "-t", ANY_TEMPLATE_NAME };
assertEquals(SUCCESS, Main.execute(args, new NullWriter()));
}
@Test
public void shouldLoadTemplateWithLeadingSlachFromTemplateLoader() {
- final String[] args = new String[] { "--basedir", TEST_TEMPLATES_DIRECTORY, "-t", "/" + ANY_TEMPLATE_NAME };
+ final String[] args = new String[] { "--template-dir", TEST_TEMPLATES_DIRECTORY, "-t", "/" + ANY_TEMPLATE_NAME };
assertEquals(SUCCESS, Main.execute(args, new NullWriter()));
}