RE: [nant-dev] Loop task delimiters

2003-02-28 Thread Matthew Mastracci
Yeah- it would a bit more re-engineering, but I think that you are
correct.  Perhaps the same structure should be applied to the delim
property as well.

On Fri, 2003-02-28 at 02:34, Simon Steele wrote:
 Wouldn't multiple sub-elements be the more XML thing to do?
 
 foreach item=Line in=C:\foo.txt delim=,
   property name=x /
   property name=y /
 /foreach
-- 
Matthew Mastracci [EMAIL PROTECTED]


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers


Re: [nant-dev] Loop task delimiters

2003-02-27 Thread Matthew Mastracci
While I'm at it, I wonder if we should put a pattern attribute on the 
includesList element of a FileSet.  I'm using these to separate some 
lists of files from the build scripts themselves, but it's nice to have 
some documentation in the file list:

---
# This is the list of projects to build
folder/x/x.csproj
folder/y/y.csproj
# Throw in all these files for good measure
folder2/**/*.csproj
-
Right now, this adds each of the lines asis.  I would then create a 
fileset like so:

!-- Include the lines from foo.txt, skipping any that look like a 
comment --
includesList name=foo.txt pattern=$[^#].* /

Any comments?

Matthew Mastracci wrote:

Should we change the following lines in the LoopTask?  Currently, the 
string is split based on a single delimiter.  Since String.Split() 
supports a character array, we can remove the char array [0] indexer 
and have it split on any character in the delim property.  I can fix 
this and check it in, if noone objects:

   case ItemTypes.String: {
   if(Delimiter != null  Delimiter.Length  0) {
   string[] items = 
_source.Split(Delimiter.ToCharArray()[0]);
   foreach(string s in items)
   DoWork(s);
   }
   else
   throw new BuildException(Invalid delim:  
+ _delim, Location);
   break;
   }

becomes:

   case ItemTypes.String: {
   if(Delimiter != null  Delimiter.Length  0) {
   string[] items = 
_source.Split(Delimiter.ToCharArray());
   foreach(string s in items)
   DoWork(s);
   }
   else
   throw new BuildException(Invalid delim:  
+ _delim, Location);
   break;
   }

It would also be nice if we could support delim and multiple 
properties for the foreach item=line task to parse a file with 
(potentially) multiple items per line.  Something along the lines of:

foreach item=Line in=C:\foo.txt delim=, property=x property=y
 echo message=copying ${x} to ${y}/
 ...
/foreach
How does this sound?



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers




---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers


RE: [nant-dev] Loop Task

2002-06-25 Thread Scott Hernandez

I thought I was one of those people :)

Anyway, the foreach was really just a test case for the TaskContainer
concept. Well, it wasn't really a test; it is useful on its own. The
ghenghis build has a script section that loops through all the sample
subdirs and builds each sample [1]. It is a lot of code, and it seemed
to me that it would be much simpler, and easier to understand if it
could be re-written with a loop task. In fact I think this was Brad's
question in his post
(http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg00
205.html) that started the idea.

The general syntax was pretty straight forward. So I started playing
with the idea of a loop. It turned out to be really simple. And I think
a coded task version is much better than writing this in a script block
every time you want to do it. Besides the whole maintenance and testing
issues that arise from putting code in a place that is edited a lot.

Right now foreach/ can iterate over Files, Folders, Lines, or a
delimitated string.
(http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg00
341.html)

The general syntax is a little clumsy, but I can't think of a better
way. 

foreach itemtype=Folders source=c:\ property=folder
anyTasks/
/

--The itemtype attribute species on of the Enum values:
public enum ItemTypes {
None,
Files,
Folders,
DelimString,
Lines
}

--The source species what to work with. It is dependant on the itemtype.

--The property attribute specifies the name of the attribute to use.
This attribute is used for the duration of the task, and the value is
returned to its original.

I don't like the itemtype/source separation, but I wanted to keep these
all in attributes so it is clear that everything else is a task and get
executed.

I'm not sure exactly what other uses there are for this looping task
than what has already been proposed. The sky is the limit :)

Oh... it also works great for counting...
foreach itemtype=DelimString source=1,2,3 property=number
echo message=I can count! I now have ${number}./
/

(I'm just kidding here, counting is over-rated.)

[1]
   target name=samples description=Builds the sample applications
depends=debug
  script language=C#
 code![CDATA[
 public static void ScriptMain(Project project) {
// Get the samples directory
string sourcePath = Path.Combine(project.BaseDirectory,
samples);

// Get all the subdirectories of the samples directory
string[] dirs = Directory.GetDirectories(sourcePath);
char sep = Path.DirectorySeparatorChar;

// Iterate
foreach(string dir in dirs) {
   int idx = dir.LastIndexOf(sep);
   if(idx = 0) {
  // Launch a second NAnt to build the sample
  System.Diagnostics.Process process = new
System.Diagnostics.Process();
  process.StartInfo.FileName = nant;
  process.StartInfo.Arguments = -buildfile: +
project.BaseDirectory + \\Genghis.build2 -D:sample= +
dir.Substring(idx+1) +  mksample;
  process.StartInfo.UseShellExecute = false;
  process.StartInfo.WorkingDirectory =
project.BaseDirectory;
  process.Start();
  process.WaitForExit();
  if(process.ExitCode != 0)
 throw new BuildException();
   }
}
 }
  ]]/code
  /script
   /target
 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:nant-developers-
 [EMAIL PROTECTED]] On Behalf Of Gerry Shaw
 Sent: Monday, June 24, 2002 10:25 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [nant-dev] Loop Task
 
 Can you help the slower people in the group by explaining a bit more
 about the foreach task.  I can see how it could print out all the
 properties
 
 * What do you plan on doing with it?
 * What is the syntax for iterating over the containers?
 * What containers can you iterate over?  properites, folders, files,
 tasks, targets??
 
 I'm probally missing something obvious but it seems a bit weird.  On
the
 chance that you needed to do something like this why not just drop
down
 into C# using the script task?  It would seem to have a lot cleaner
 syntax IMO.



---
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members! 
JabConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Bernard Vander Beken

+1 for NAnt.Core 

Bernard

- Original Message - 
From: Scott Hernandez [EMAIL PROTECTED]
[...]
 Does anyone have an argument as to whether this should go into the NAnt
 core or NAntContrib? I'm leaning towards core.




---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [nant-dev] Loop Task

2002-06-24 Thread Kevin Dente

Sorry if I'm getting too crazy here, but how about
making elements like FileSet implement IEnumerable,
and have the foreach task capable of iterating over
anything that implements that interface? 

That way you don't need to update the foreach task to
add a new element - to make any element for-each-able,
just add an IEnumerable implementation to the element.
I've been working on a FileList class - it would work
for that also. And OptionSet if we decide to keep it. 

--- Scott Hernandez [EMAIL PROTECTED] wrote:
 What would you think the xml would look like?
 
 foreach itemtype=fileset source=id
 property=item
   echo message=${item}/
 /foreach
 
 BTW. I've now got the embedded version working.
 foreach itemtype=Folders source=c:\
 property=currDir
   echo message=${currDir}/
 /foreach
 
 It works; after the first compile and everything.
 
 I will commit the abstract TaskWithEmbeddedTasks
 class later today. This
 abstract class will evaluate all internal elements
 as tasks. It skips
 anything with a BuildElementAttribute, or that is in
 a special list of
 excluded element names. The LoopTask now derives
 from this.
 
 
 Does anyone have an argument as to whether this
 should go into the NAnt
 core or NAntContrib? I'm leaning towards core.
 
  -Original Message-
  From: [EMAIL PROTECTED]
 [mailto:nant-developers-
  [EMAIL PROTECTED]] On Behalf Of Kevin
 Dente
  Sent: Monday, June 17, 2002 11:08 AM
  To: Scott Hernandez;
 [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: Re: [nant-dev] Loop Task
  
  How about looping over a FileSet?
  
  --- Scott Hernandez [EMAIL PROTECTED] wrote:
   I've posted this to both the Nant and
 NAntContrib
   dev lists, as well as
   to nant-user. I'm thinking that discussions
 about
   new task ideas should
   probably go on the nant-users list. And we
 should
   use NAntContrib to
   discuss changes, updates, or removals of
 existing
   NAntContrib
   tasks/utils. So, I urge you to join the
 Nant-users
   list
  
 

(http://lists.sourceforge.net/lists/listinfo/nant-users).
  
   I've created a loop (foreach) task.
  
   Right now it can loop over directory items
   (files/folders) or
   delimitated strings.
  
   Here is an example of how it works.
  
 foreach itemtype=Folders source=c:\
   target=echoDir
   property=folder/
 target name=echoDir
 echo message=${folder} /
 /target
  
 foreach itemtype=Files source=c:\
   target=echoFile
   property=file/
 target name=echoFile
 echo message=${file} /
 /target
  
 foreach itemtype=DelimString
 source=a,b,c,d,e
   delim=,
   target=echoString property=string/
 target name=echoString
 echo message=${string} /
 /target
  
 foreach itemtype=DelimString source=1 2 3 4
 5 6
   7 delim= 
   target=echoCount property=count/
 target name=echoCount
 echo message=${count} /
 /target
  
   In the next version (a few weeks away at best I
   think) I want to support
   embedded tasks. So you won't need to use a
 target.
  
 foreach itemtype=DelimString source=1 2 3 4
 5 6
   7 delim= 
   target=echoCount property=count/
 echo message=${count} /
 /foreach
  
   Is this task worthwhile without embedded task
   support?
  
   Are there any other types of looping we should
   support?
  
   I'm not sure how happy I am with the attribute
   names, anyone have any
   better suggestions?
  
  
  
  
 

___
  
   Sponsored by:
   ThinkGeek at http://www.ThinkGeek.com/
   ___
   Nant-developers mailing list
   [EMAIL PROTECTED]
  
 

https://lists.sourceforge.net/lists/listinfo/nant-developers
  
  
  __
  Do You Yahoo!?
  Yahoo! - Official partner of 2002 FIFA World Cup
  http://fifaworldcup.yahoo.com
  
 

___
  
  Sponsored by:
  ThinkGeek at http://www.ThinkGeek.com/
  ___
  Nant-developers mailing list
  [EMAIL PROTECTED]
 

https://lists.sourceforge.net/lists/listinfo/nant-developers
 
 
 

---
 Sponsored by:
 ThinkGeek at http://www.ThinkGeek.com/
 ___
 Nant-developers mailing list
 [EMAIL PROTECTED]

https://lists.sourceforge.net/lists/listinfo/nant-developers


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [nant-dev] Loop Task

2002-06-24 Thread Scott Hernandez

And we would call .ToString() on each iteration for the property value?
I'm fine with that.

But what would the xml look like?

foreach itemtype=IEnumarable source=??? property=item

echo message=${item}/
/

Really the question is how we would get that object to the foreach. It
would need to be embedded, or referenced. Right now a Target is the only
reference-able type.


 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:nant-developers-
 [EMAIL PROTECTED]] On Behalf Of Kevin Dente
 Sent: Monday, June 24, 2002 1:53 PM
 To: Scott Hernandez; [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: [nant-dev] Loop Task
 
 Sorry if I'm getting too crazy here, but how about
 making elements like FileSet implement IEnumerable,
 and have the foreach task capable of iterating over
 anything that implements that interface?
 
 That way you don't need to update the foreach task to
 add a new element - to make any element for-each-able,
 just add an IEnumerable implementation to the element.
 I've been working on a FileList class - it would work
 for that also. And OptionSet if we decide to keep it.
 
 --- Scott Hernandez [EMAIL PROTECTED] wrote:
  What would you think the xml would look like?
 
  foreach itemtype=fileset source=id
  property=item
  echo message=${item}/
  /foreach
 
  BTW. I've now got the embedded version working.
  foreach itemtype=Folders source=c:\
  property=currDir
  echo message=${currDir}/
  /foreach
 
  It works; after the first compile and everything.
 
  I will commit the abstract TaskWithEmbeddedTasks
  class later today. This
  abstract class will evaluate all internal elements
  as tasks. It skips
  anything with a BuildElementAttribute, or that is in
  a special list of
  excluded element names. The LoopTask now derives
  from this.
 
 
  Does anyone have an argument as to whether this
  should go into the NAnt
  core or NAntContrib? I'm leaning towards core.



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [nant-dev] Loop Task

2002-06-24 Thread Kevin Dente

Well, if we add the id/refid stuff we've been talking
about, this would dovetail nicely with that - just
pass in an ID to an element that supports IEnumerable.


foreach itemtype=Element source=element_id 
property=item
echo message=${item}/
/foreach

--- Scott Hernandez [EMAIL PROTECTED] wrote:
 And we would call .ToString() on each iteration for
 the property value?
 I'm fine with that.
 
 But what would the xml look like?
 
 foreach itemtype=IEnumarable source=???
 property=item
   
   echo message=${item}/
 /
 
 Really the question is how we would get that object
 to the foreach. It
 would need to be embedded, or referenced. Right now
 a Target is the only
 reference-able type.
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
 [mailto:nant-developers-
  [EMAIL PROTECTED]] On Behalf Of Kevin
 Dente
  Sent: Monday, June 24, 2002 1:53 PM
  To: Scott Hernandez;
 [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: [nant-dev] Loop Task
  
  Sorry if I'm getting too crazy here, but how about
  making elements like FileSet implement
 IEnumerable,
  and have the foreach task capable of iterating
 over
  anything that implements that interface?
  
  That way you don't need to update the foreach task
 to
  add a new element - to make any element
 for-each-able,
  just add an IEnumerable implementation to the
 element.
  I've been working on a FileList class - it would
 work
  for that also. And OptionSet if we decide to keep
 it.
  
  --- Scott Hernandez [EMAIL PROTECTED] wrote:
   What would you think the xml would look like?
  
   foreach itemtype=fileset source=id
   property=item
 echo message=${item}/
   /foreach
  
   BTW. I've now got the embedded version working.
   foreach itemtype=Folders source=c:\
   property=currDir
 echo message=${currDir}/
   /foreach
  
   It works; after the first compile and
 everything.
  
   I will commit the abstract TaskWithEmbeddedTasks
   class later today. This
   abstract class will evaluate all internal
 elements
   as tasks. It skips
   anything with a BuildElementAttribute, or that
 is in
   a special list of
   excluded element names. The LoopTask now derives
   from this.
  
  
   Does anyone have an argument as to whether this
   should go into the NAnt
   core or NAntContrib? I'm leaning towards core.
 
 
 

---
 Sponsored by:
 ThinkGeek at http://www.ThinkGeek.com/
 ___
 Nant-developers mailing list
 [EMAIL PROTECTED]

https://lists.sourceforge.net/lists/listinfo/nant-developers


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Tomas Restrepo

Hi Scott,

 BTW. I've now got the embedded version working.
 foreach itemtype=Folders source=c:\ property=currDir
 echo message=${currDir}/
 /foreach

 It works; after the first compile and everything.

That's great! In the general sense, I think this is much useful,
particularly as we could use it as a base for an Ant-like Conditions
framework.

 Does anyone have an argument as to whether this should go into the NAnt
 core or NAntContrib? I'm leaning towards core.

I think this should be core functionality. That said, I gotta admit I'm not
crazy about the name of the class... ;)

--
Tomas Restrepo
[EMAIL PROTECTED]



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Scott Hernandez

I'm open for suggestions on a better name. :)

 -Original Message-
 From: Tomas Restrepo


[snip]
 That's great! In the general sense, I think this is much useful,
 particularly as we could use it as a base for an Ant-like Conditions
 framework.

Yep, I was just starting to make a list of those... :)

[snip]
 I think this should be core functionality. That said, I gotta admit
I'm
 not
 crazy about the name of the class... ;)







---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Tomas Restrepo

Scott,

 I'm open for suggestions on a better name. :)

How about CompositeTask? 

-- 
Tomas Restrepo
[EMAIL PROTECTED]



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Kevin Dente

I actually kinda like foreach.

--- Scott Hernandez [EMAIL PROTECTED] wrote:
 I'm open for suggestions on a better name. :)
 
  -Original Message-
  From: Tomas Restrepo
 
 
 [snip]
  That's great! In the general sense, I think this
 is much useful,
  particularly as we could use it as a base for an
 Ant-like Conditions
  framework.
 
 Yep, I was just starting to make a list of those...
 :)
 
 [snip]
  I think this should be core functionality. That
 said, I gotta admit
 I'm
  not
  crazy about the name of the class... ;)
 
 
 
 
 
 
 

---
 Sponsored by:
 ThinkGeek at http://www.ThinkGeek.com/
 ___
 Nant-developers mailing list
 [EMAIL PROTECTED]

https://lists.sourceforge.net/lists/listinfo/nant-developers


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Tomas Restrepo

Hi Kevin,

 I actually kinda like foreach.

Me too. I was referring, however, to TaskWithEmbeddedTasks, not foreach ;)

-- 
Tomas Restrepo
[EMAIL PROTECTED]



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Kevin Dente

Ah, oops, gotcha. OK, I'll agree with you on that one.
:)

--- Tomas Restrepo [EMAIL PROTECTED] wrote:
 Hi Kevin,
 
  I actually kinda like foreach.
 
 Me too. I was referring, however, to
 TaskWithEmbeddedTasks, not foreach ;)
 
 -- 
 Tomas Restrepo
 [EMAIL PROTECTED]
 
 
 

---
 Sponsored by:
 ThinkGeek at http://www.ThinkGeek.com/
 ___
 Nant-developers mailing list
 [EMAIL PROTECTED]

https://lists.sourceforge.net/lists/listinfo/nant-developers


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Scott Hernandez

What about TaskContainer?

 -Original Message-
 From: Tomas Restrepo
 
 Scott,
 
  I'm open for suggestions on a better name. :)
 
 How about CompositeTask?



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



Re: [NAntC-Dev] RE: [nant-dev] Loop Task

2002-06-24 Thread Tomas Restrepo

Scott,

 What about TaskContainer?

Either would work for me...

-- 
Tomas Restrepo
[EMAIL PROTECTED]



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



RE: [nant-dev] Loop Task

2002-06-24 Thread Gerry Shaw

Can you help the slower people in the group by explaining a bit more
about the foreach task.  I can see how it could print out all the
properties 

* What do you plan on doing with it?
* What is the syntax for iterating over the containers?
* What containers can you iterate over?  properites, folders, files,
tasks, targets??

I'm probally missing something obvious but it seems a bit weird.  On the
chance that you needed to do something like this why not just drop down
into C# using the script task?  It would seem to have a lot cleaner
syntax IMO.



---
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers