You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Nicolas Lalevée <ni...@hibnet.org> on 2012/08/29 15:35:37 UTC

Argument Processor "plugin"

I would like to add to Ant the possibility to define custom command line options.

This is motivated by the experiment I am doing with the AntDSL and the import model I am trying to revisit (if anybody is interested, at some point I will probably discuss it on easyant-dev, but we can also discuss here). I want things to happen before the build file is being parsed and I want it to happen only if the end user has requested it.

I have not committed it because it is a kind of important door opening in Ant's API. And it is only required by an experiment. EasyAnt has some custom arguments too, it could benefit from it, but for now it has it own "main" implementation and so has a full control of argument parsing. So there is no real use case. yet :)

So I would like some feed back before proceeding. The suggested patch is here:
https://svn.apache.org/repos/asf/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch

Nicolas


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Argument Processor "plugin"

Posted by Matt Benson <gu...@gmail.com>.
On Wed, Aug 29, 2012 at 10:42 AM, Nicolas Lalevée
<ni...@hibnet.org> wrote:
>
> Le 29 août 2012 à 16:41, Matt Benson a écrit :
>
>> Comments:
>>
>> - ArgumentProcessor#readArgument() should return a negative number for
>> unsupported args, otherwise a separate boolean #supports(arg) method
>> and a declared IllegalArgumentException from #readArgument()
>
> Reviewing this, maybe a better method would be:
> int readArgument(String[] args, int pos);
> which returns the new position, the same as the one provided is not supported.
> That way we can have a variable number of custom arguments.

Sounds good.  Reminds me of ParsePosition etc.

>
>> - Prefer e.g. Appendable to StringBuffer in
>> ArgumentProcessor#printUsage() signature, or unless there is a good
>> reason for the configurable line separator, PrintStream or PrintWriter
>
> Actually, in the current implementation, any reason all the message is buffered before being put to System.out ?
> Any reason not to do System.out.println rather than StringBuffer.append( + line.separator) ?

Not sure, but using PrintStream would allow Ant Main to have the
ArgumentProcessor write directly to System.out or not.  :D

Matt

>
>> I am generally in favor of the idea, so as long as the APIs are as
>> nice as they can be all the internals are negotiable.
>
> Thanks for the review,
> Nicolas
>
>>
>> Thanks,
>> Matt
>>
>> On Wed, Aug 29, 2012 at 8:35 AM, Nicolas Lalevée
>> <ni...@hibnet.org> wrote:
>>> I would like to add to Ant the possibility to define custom command line options.
>>>
>>> This is motivated by the experiment I am doing with the AntDSL and the import model I am trying to revisit (if anybody is interested, at some point I will probably discuss it on easyant-dev, but we can also discuss here). I want things to happen before the build file is being parsed and I want it to happen only if the end user has requested it.
>>>
>>> I have not committed it because it is a kind of important door opening in Ant's API. And it is only required by an experiment. EasyAnt has some custom arguments too, it could benefit from it, but for now it has it own "main" implementation and so has a full control of argument parsing. So there is no real use case. yet :)
>>>
>>> So I would like some feed back before proceeding. The suggested patch is here:
>>> https://svn.apache.org/repos/asf/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch
>>>
>>> Nicolas
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Argument Processor "plugin"

Posted by Nicolas Lalevée <ni...@hibnet.org>.
Le 29 août 2012 à 16:41, Matt Benson a écrit :

> Comments:
> 
> - ArgumentProcessor#readArgument() should return a negative number for
> unsupported args, otherwise a separate boolean #supports(arg) method
> and a declared IllegalArgumentException from #readArgument()

Reviewing this, maybe a better method would be:
int readArgument(String[] args, int pos);
which returns the new position, the same as the one provided is not supported.
That way we can have a variable number of custom arguments.

> - Prefer e.g. Appendable to StringBuffer in
> ArgumentProcessor#printUsage() signature, or unless there is a good
> reason for the configurable line separator, PrintStream or PrintWriter

Actually, in the current implementation, any reason all the message is buffered before being put to System.out ?
Any reason not to do System.out.println rather than StringBuffer.append( + line.separator) ?

> I am generally in favor of the idea, so as long as the APIs are as
> nice as they can be all the internals are negotiable.

Thanks for the review,
Nicolas

> 
> Thanks,
> Matt
> 
> On Wed, Aug 29, 2012 at 8:35 AM, Nicolas Lalevée
> <ni...@hibnet.org> wrote:
>> I would like to add to Ant the possibility to define custom command line options.
>> 
>> This is motivated by the experiment I am doing with the AntDSL and the import model I am trying to revisit (if anybody is interested, at some point I will probably discuss it on easyant-dev, but we can also discuss here). I want things to happen before the build file is being parsed and I want it to happen only if the end user has requested it.
>> 
>> I have not committed it because it is a kind of important door opening in Ant's API. And it is only required by an experiment. EasyAnt has some custom arguments too, it could benefit from it, but for now it has it own "main" implementation and so has a full control of argument parsing. So there is no real use case. yet :)
>> 
>> So I would like some feed back before proceeding. The suggested patch is here:
>> https://svn.apache.org/repos/asf/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch
>> 
>> Nicolas
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Argument Processor "plugin"

Posted by Matt Benson <gu...@gmail.com>.
Comments:

- ArgumentProcessor#readArgument() should return a negative number for
unsupported args, otherwise a separate boolean #supports(arg) method
and a declared IllegalArgumentException from #readArgument()
- Prefer e.g. Appendable to StringBuffer in
ArgumentProcessor#printUsage() signature, or unless there is a good
reason for the configurable line separator, PrintStream or PrintWriter

I am generally in favor of the idea, so as long as the APIs are as
nice as they can be all the internals are negotiable.

Thanks,
Matt

On Wed, Aug 29, 2012 at 8:35 AM, Nicolas Lalevée
<ni...@hibnet.org> wrote:
> I would like to add to Ant the possibility to define custom command line options.
>
> This is motivated by the experiment I am doing with the AntDSL and the import model I am trying to revisit (if anybody is interested, at some point I will probably discuss it on easyant-dev, but we can also discuss here). I want things to happen before the build file is being parsed and I want it to happen only if the end user has requested it.
>
> I have not committed it because it is a kind of important door opening in Ant's API. And it is only required by an experiment. EasyAnt has some custom arguments too, it could benefit from it, but for now it has it own "main" implementation and so has a full control of argument parsing. So there is no real use case. yet :)
>
> So I would like some feed back before proceeding. The suggested patch is here:
> https://svn.apache.org/repos/asf/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch
>
> Nicolas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org