Question

I'd like to augment NAntContrib's set of Perforce tasks by adding the p4 labels task.

The p4labels task would have to return a collection of labels, or even ideally, a collection of label info: name, date/time, description.

Looking into NAntContrib's code for other call (p4info for example), it looks like it's rather easy to return simple strings from a task, but I've not managed to find a way to return a collection of labels. A potential use would be to later pass this collection to a function to get the latest label in the collection or to a foreach task to iterate over to deal with each within the collection, for example.

Is this even possible in NAnt? From all I've seen, it seems you can declare sets and collections, but not return them from a task or a function.

For the record, I've declared a LabelInfo NAnt type as well as a LabelInfoCollection, but really I don't know how I would return one from a task.

Any tips are welcome.

Was it helpful?

Solution

Looking at NAntContrib's sql task's strategy to deal with returning a set of values, it seems a solution would be to store the data in a file and pass that file to whatever function or task requiring the data.

It'd then possible to pass this to file to a foreach task that can iterate over the lines in the file. Data stored in CSV format is very easy to parse:

<p4labels user="bob" filter="*VerifiedBuild*" max=100 output="myfile.csv" />
<foreach item="Line" in="myfile.csv" delim="," property="label,date,comment">
  <echo message="Label: ${label} Created on: ${date}   -   ${comment}" />
</foreach>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top