Sure,
A version with filest support would be great.

Ian

wouldn't it be better to have something similar to the Ant concat task
(http://ant.apache.org/manual/CoreTasks/concat.html), which allows files to
be concatenated or the tasks inline text be appended (or overwritten) to the
destination file ?

If no destination file is specified, output will be written to the build
log.  It should be pretty easy to port to .NET.

Gert

----- Original Message ----- From: "Ian MacLean" <[EMAIL PROTECTED]>
To: "Sascha Andres" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, September 17, 2003 6:12 AM
Subject: Re: [nant-dev] New task: cat





Thanks Sascha,
This could be pretty useful. There was a post on the mono list recently
where someone wanted to merge a bunch of .resx files into a single
.resources output. This combined with resgen would give that functioality.
I think this fits in NAnt.Core.Tasks unless anyone has any objections
Ian



Hi,

I had a problem where I merge sourcefiles into one assembly,
while I use them normally in more than one assembly to link
only what I need.

I'm using the ndoc task to document, and hence it's missing
the namespace descriptions, if I do not create a new
namespace.xml for the merged assembly.

Basicly appending all namespace.xml files from the seperated
assemblies into one new would do the job. I would do this
with cat under unix, but I found it nice to have a task
doing this.

There are three attributes:

* file
* pipe
* append

The last two are optional. The first one is the file to cat.
If this is the only attribute given, it will print it on the
screen. If pip is given, it will create - that means
overwrite, since append defaults to false - the given file
and insert the contents of file. If append is true the
content is appended where I've reached what I wanted.

I just think I post it here for inclusion in NAnt or
NAnt-contrib.

-sa



------------------------------------------------------------------------

// NAnt - A .NET build tool
// Copyright (C) 2001-2002 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307


USA


// Sascha Andres ([EMAIL PROTECTED])

using System;
using System.Globalization;
using System.Xml;
using System.IO;

using NAnt.Core.Attributes;
using NAnt.Core.Util;

namespace NAnt.Core.Tasks {
/// <summary>
/// A somehow compareable task to 'cat' from a unix/linux system
/// </summary>
/// <example>
/// <para>Prints a file on the screen</para>
/// <code>
/// <![CDATA[
/// <cat file="input.txt" />
/// ]]>
/// </code>
/// <para>Prints a file to an other file. Overwrite is the


default!</para>


  ///   <code>
  ///     <![CDATA[
  /// <cat file="input.txt" pipe="output.txt" />
  ///     ]]>
  ///   </code>
  ///   <para>Prints two files to one other file.</para>
  ///   <code>
  ///     <![CDATA[
  /// <cat file="input.txt" pipe="output.txt" />
  /// <cat file="input2.txt" pipe="output.txt" append="true" />
  ///     ]]>
  ///   </code>
  /// </example>
  [TaskName("cat")]
  public class CatTask : Task {
      #region Private Instance Fields

      private string _filein = "";
      private string _fileout = "";
      private string _append = Boolean.FalseString;

#endregion Private Instance Fields

#region Public Instance Properties

      /// <summary>
      /// The file to display.
      /// </summary>
      [TaskAttribute("file", Required=true)]
      public string File {
          get { return _filein; }
          set {
                  _filein = value;
          }
      }

      /// <summary>
      /// Write the output to
      /// </summary>
      [TaskAttribute("pipe", Required=false)]
      public string Pipe {
          get { return _fileout; }
          set {
                  _fileout = value;
          }
      }

      /// <summary>
      /// Append to file
      /// </summary>
      [TaskAttribute("append", Required=false)]
      [BooleanValidator()]
      public string Append {
          get { return _append; }
          set {
              _append = value;
          }
      }

#endregion Public Instance Properties

#region Override implementation of Task

/// <summary>
/// Outputs the message to the build log.
/// </summary>
protected override void ExecuteTask() {
bool bUseFile = false;
using (StreamReader sr = new StreamReader(_filein)) {
StreamWriter sw = null;
if (_fileout != "") {
bUseFile = true;
sw = new StreamWriter(_fileout,


Convert.ToBoolean(_append));


          }
          while(true) {
              string strLine = sr.ReadLine();
              if (strLine == null) {
              break;
              }
              if (!bUseFile) {
              Log(Level.Info, LogPrefix + strLine);
              } else {
              sw.WriteLine(strLine);
              }
          }
          if (bUseFile) {
              sw.Flush();
              sw.Close();
              sw = null;
          }
          }
      }

      #endregion Override implementation of Task
  }
}







------------------------------------------------------- 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

Reply via email to