Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enhance dita command example for Ant with optional arguments #159

Closed
stefan-jung opened this issue Oct 11, 2017 · 1 comment
Closed

Enhance dita command example for Ant with optional arguments #159

stefan-jung opened this issue Oct 11, 2017 · 1 comment
Assignees
Labels
enhancement Changes to an existing topic or feature
Milestone

Comments

@stefan-jung
Copy link
Contributor

stefan-jung commented Oct 11, 2017

This is the snippet:

<macrodef name="dita-cmd">
    <attribute name="input"/>
    <attribute name="format"/>
    <attribute name="propertyfile"/>
    <sequential>
      <exec executable="${dita.dir}/bin/dita">
        <arg line="-i @{input} -f @{format} -propertyfile @{propertyfile}"/>
      </exec>
    </sequential>
  </macrodef>

Unfortunately the Ant <macrodef> is not handy for using optional attributes. So, if you'd like to create a macro that also supports --filter, like so:

<macrodef name="dita-cmd">
    <attribute name="input"/>
    <attribute name="format"/>
    <attribute name="filter"/>
    <attribute name="propertyfile"/>
    <sequential>
      <exec executable="${dita.dir}/bin/dita">
        <arg line="-i @{input} -f @{format} --filter=@{filter} --propertyfile=@{propertyfile}"/>
      </exec>
    </sequential>
  </macrodef>

... it would break, if you'd like to call the macro without a filter attribute.

I recommend to add a note that recommends to pass filter files by using the args.filter property in the propertyfile.

@infotexture infotexture self-assigned this Oct 11, 2017
@infotexture infotexture added the enhancement Changes to an existing topic or feature label Oct 11, 2017
@infotexture infotexture added this to the 3.0 milestone Oct 11, 2017
@infotexture
Copy link
Member

This behavior is not peculiar to the filter parameter, so I'm not sure it's worth mentioning that by name. As the Ant MacroDef task docs explain:

The values of the attributes get substituted into the templated task.
The attributes will be required attributes unless a default value has been set.

I'll add a note to clarify that any optional parameters should be defined in .properties files.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Changes to an existing topic or feature
Projects
None yet
Development

No branches or pull requests

2 participants