package org.codehaus.modello;

/*
 * Copyright (c) 2004, Jason van Zyl
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

import java.io.FileReader;
import java.util.Properties;

/**
 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
 * @version $Id$
 */
public class ModelloCli
{
    private static String modelFile;

    private static String outputType;

    private static Properties parameters;

//    private static String outputDirectory;

//    private static String modelVersion;

//    private static boolean packageWithVersion;

    public static void main( String[] args )
        throws Exception
    {
        Modello modello = new Modello();

        parseArgumentsFromCommandLine( args );

//        modello.initialize();

        modello.generate( new FileReader( modelFile ), outputType, parameters );
//        modello.work( new File( modelFile ), mode, new File( outputDirectory ), modelVersion, packageWithVersion );
    }

    public static void parseArgumentsFromCommandLine( String[] args )
        throws Exception
    {
        if ( args.length != 5 )
        {
            System.err.println( "Usage: modello <model> <outputType> <output directory> <modelVersion> <packageWithVersion>" );

            System.exit( 1 );
        }

        modelFile = args[0];

        outputType = args[1];

        parameters = new Properties();

        String outputDirectory = args[2];

        String modelVersion = args[3];

        String packageWithVersion = args[4];

        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, outputDirectory );

        parameters.setProperty( ModelloParameterConstants.VERSION, modelVersion );

        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, packageWithVersion );
    }
}

@@ -1159,20 +1159,22 @@
 java.io.
-File
+String
 Reader;%0A
@@ -1203,16 +1203,105 @@
 rties;%0A%0A
+import org.codehaus.plexus.util.FileUtils;%0Aimport org.codehaus.plexus.util.StringUtils;%0A%0A
 /**%0A * @
@@ -1869,24 +1869,280 @@
 tialize();%0A%0A
+        String fileString = FileUtils.fileRead(modelFile);%0A%0A        fileString = StringUtils.replace( fileString, %22%3Cdescription%3E%22, %22%3Cdescription%3E%3C!%5BCDATA%5B%22 );%0A%0A        fileString = StringUtils.replace( fileString, %22%3C/description%3E%22, %22%5D%5D%3E%3C/description%3E%22 );%0A%0A
         mode
@@ -2163,20 +2163,22 @@
 new 
-File
+String
 Reader( 
 mode
@@ -2173,25 +2173,26 @@
 Reader( 
-modelFile
+fileString
  ), outp

Change in memory the description tag to a CDATA for authorize html in it.