[
https://issues.apache.org/jira/browse/FREEMARKER-135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Siegfried Goeschl updated FREEMARKER-135:
-----------------------------------------
Description:
The current implementation of `freemarker-cli` provides all datasources as list
to be rendered with the template. Individual datasources can be accessed via
index or wildcard search based on the underlying file name. This forces the
user to pass the datasources in the correct order when the template process
more than on datasource or rely on file naming conventions.
So we want to allow the naming of the datasources on the command line.
A few thoughts along the line
* A user might also want to provide additional metadata, e.g. `charset` or
`mimetype`
* We want to support positional parameters with `Picocli` so all that
information should go into a single string
The following usage should be supported
{noformat}
# Single positional parameter
> freemarker-cli -t templates/info.ftl users.csv
> freemarker-cli -t templates/info.ftl file:///users.csv
# Multiple positional parameters
> freemarker-cli -t templates/info.ftl users.csv transactions.csv
> freemarker-cli -t templates/info.ftl users.csv file:///transactions.csv
> freemarker-cli -t templates/info.ftl file:///users.csv
> file:///transactions.csv
# Short option
> freemarker-cli -t templates/info.ftl -d users.csv
> freemarker-cli -t templates/info.ftl -d file:///users.csv
> freemarker-cli -t templates/info.ftl -d file:///users.csv -d
> file:///transactions.csv
# Long option
> freemarker-cli -t templates/info.ftl --datasource users.csv
> freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> --datasource file:///transactions.csv
# Named datasource using file name
> freemarker-cli -t templates/info.ftl users=users.csv
> freemarker-cli -t templates/info.ftl -d users=users.csv
> freemarker-cli -t templates/info.ftl --datasource users=users.csv
# Named datasource using URI
> freemarker-cli -t templates/info.ftl -d users=file:///users.csv
> freemarker-cli -t templates/info.ftl --datasource users=users.csv
# Named datasource using URI and fragments
> freemarker-cli -t templates/info.ftl -d users=file:///users.csv#charset=UTF-16
> freemarker-cli -t templates/info.ftl --datasource
> users=file:///users.csv#charset=UTF-16
# Named datasource using URI and fragments with multiple parameters
> freemarker-cli -t templates/info.ftl --datasource
> users=file:///users.csv#charset=UTF-16&mimetype=text/csv
# Mix and match the various options
> freemarker-cli -t templates/info.ftl --datasource users=file:///users.csv
> transactions=transactions.csv
{noformat}
As discusses on the mailing list some sort of grouping mechanism of
`Datasource`s would be useful - the following usage should be supported
{noformat}
# Define a group "admin"
> freemarker-cli -t templates/info.ftl
> users-xxx:admin=site/sample/csv/some-user-file.csv
> freemarker-cli -t templates/info.ftl -d
> users-xxx:admin=site/sample/csv/some-user-file.csv
> freemarker-cli -t templates/info.ftl --datasource
> users-xxx:admin=site/sample/csv/some-user-file.csv
{noformat}
was:
The current implementation of `freemarker-cli` provides all datasources as list
to be rendered with the template. Individual datasources can be accessed via
index or wildcard search based on the underlying file name. This forces the
user to pass the datasources in the correct order when the template process
more than on datasource or rely on file naming conventions.
So we want to allow the naming of the datasources on the command line.
A few thoughts along the line
* A user might also want to provide additional metadata, e.g. `charset` or
`mimetype`
* We want to support positional parameters with `Picocli` so all that
information should go into a single string
The following usage should be supported
{noformat}
# Single positional parameter
> freemarker-cli -t templates/info.ftl users.csv
> freemarker-cli -t templates/info.ftl file:///users.csv
# Multiple positional parameters
> freemarker-cli -t templates/info.ftl users.csv transactions.csv
> freemarker-cli -t templates/info.ftl users.csv file:///transactions.csv
> freemarker-cli -t templates/info.ftl file:///users.csv
> file:///transactions.csv
# Short option
> freemarker-cli -t templates/info.ftl -d users.csv
> freemarker-cli -t templates/info.ftl -d file:///users.csv
> freemarker-cli -t templates/info.ftl -d file:///users.csv -d
> file:///transactions.csv
# Long option
> freemarker-cli -t templates/info.ftl --datasource users.csv
> freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> --datasource file:///transactions.csv
# Named datasource using file name
> freemarker-cli -t templates/info.ftl users=users.csv
> freemarker-cli -t templates/info.ftl -d users=users.csv
> freemarker-cli -t templates/info.ftl --datasource users=users.csv
# Named datasource using URI
> freemarker-cli -t templates/info.ftl -d users=file:///users.csv
> freemarker-cli -t templates/info.ftl --datasource users=users.csv
# Named datasource using URI and fragments
> freemarker-cli -t templates/info.ftl -d users=file:///users.csv#charset=UTF-16
> freemarker-cli -t templates/info.ftl --datasource
> users=file:///users.csv#charset=UTF-16
# Named datasource using URI and fragments with multiple parameters
> freemarker-cli -t templates/info.ftl --datasource
> users=file:///users.csv#charset=UTF-16&mimetype=text/csv
# Mix and match the various options
> freemarker-cli -t templates/info.ftl --datasource users=file:///users.csv
> transactions=transactions.csv
{noformat}
As discusses on the mailing list some sort of grouping mechanism of
`Datasource`s would be useful - the following usage should be supported
{noformat}
# Define a group "admin"
> freemarker-cli -t templates/info.ftl
> users-xxx:admin=site/sample/csv/some-user-file.csv#charset=UTF-16
> freemarker-cli -t templates/info.ftl -d
> users-xxx:admin=site/sample/csv/some-user-file.csv#charset=UTF-16
> freemarker-cli -t templates/info.ftl --datasource
> users-xxx:admin=site/sample/csv/some-user-file.csv#charset=UTF-16
{noformat}
> freemarker-generator-cli: Support user-supplied names for datasources
> ---------------------------------------------------------------------
>
> Key: FREEMARKER-135
> URL: https://issues.apache.org/jira/browse/FREEMARKER-135
> Project: Apache Freemarker
> Issue Type: Task
> Reporter: Siegfried Goeschl
> Assignee: Siegfried Goeschl
> Priority: Major
>
> The current implementation of `freemarker-cli` provides all datasources as
> list to be rendered with the template. Individual datasources can be accessed
> via index or wildcard search based on the underlying file name. This forces
> the user to pass the datasources in the correct order when the template
> process more than on datasource or rely on file naming conventions.
> So we want to allow the naming of the datasources on the command line.
> A few thoughts along the line
> * A user might also want to provide additional metadata, e.g. `charset` or
> `mimetype`
> * We want to support positional parameters with `Picocli` so all that
> information should go into a single string
> The following usage should be supported
> {noformat}
> # Single positional parameter
> > freemarker-cli -t templates/info.ftl users.csv
> > freemarker-cli -t templates/info.ftl file:///users.csv
> # Multiple positional parameters
> > freemarker-cli -t templates/info.ftl users.csv transactions.csv
> > freemarker-cli -t templates/info.ftl users.csv file:///transactions.csv
> > freemarker-cli -t templates/info.ftl file:///users.csv
> > file:///transactions.csv
> # Short option
> > freemarker-cli -t templates/info.ftl -d users.csv
> > freemarker-cli -t templates/info.ftl -d file:///users.csv
> > freemarker-cli -t templates/info.ftl -d file:///users.csv -d
> > file:///transactions.csv
> # Long option
> > freemarker-cli -t templates/info.ftl --datasource users.csv
> > freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> > freemarker-cli -t templates/info.ftl --datasource file:///users.csv
> > --datasource file:///transactions.csv
> # Named datasource using file name
> > freemarker-cli -t templates/info.ftl users=users.csv
> > freemarker-cli -t templates/info.ftl -d users=users.csv
> > freemarker-cli -t templates/info.ftl --datasource users=users.csv
> # Named datasource using URI
> > freemarker-cli -t templates/info.ftl -d users=file:///users.csv
> > freemarker-cli -t templates/info.ftl --datasource users=users.csv
> # Named datasource using URI and fragments
> > freemarker-cli -t templates/info.ftl -d
> > users=file:///users.csv#charset=UTF-16
> > freemarker-cli -t templates/info.ftl --datasource
> > users=file:///users.csv#charset=UTF-16
> # Named datasource using URI and fragments with multiple parameters
> > freemarker-cli -t templates/info.ftl --datasource
> > users=file:///users.csv#charset=UTF-16&mimetype=text/csv
> # Mix and match the various options
> > freemarker-cli -t templates/info.ftl --datasource users=file:///users.csv
> > transactions=transactions.csv
> {noformat}
> As discusses on the mailing list some sort of grouping mechanism of
> `Datasource`s would be useful - the following usage should be supported
> {noformat}
> # Define a group "admin"
> > freemarker-cli -t templates/info.ftl
> > users-xxx:admin=site/sample/csv/some-user-file.csv
> > freemarker-cli -t templates/info.ftl -d
> > users-xxx:admin=site/sample/csv/some-user-file.csv
> > freemarker-cli -t templates/info.ftl --datasource
> > users-xxx:admin=site/sample/csv/some-user-file.csv
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)