Package ch.pollet.jzic

Source Code of ch.pollet.jzic.Main

package ch.pollet.jzic;


import ch.pollet.jzic.compiler.Compiler;
import ch.pollet.jzic.writer.Writer;
import ch.pollet.jzic.datetime.DateTimeException;
import ch.pollet.jzic.parser.Parser;
import ch.pollet.jzic.parser.ParserException;
import ch.pollet.jzic.timezone.Database;
import com.martiansoftware.jsap.JSAP;
import com.martiansoftware.jsap.JSAPException;
import com.martiansoftware.jsap.JSAPResult;
import java.io.IOException;
import java.util.Iterator;

/**
*
* @author Christophe Pollet
*/
public class Main {
    public static void main(String[] args) throws ParserException, IOException, DateTimeException, JSAPException {
        JSAP jsap = new ArgumentsParser();
        JSAPResult config = jsap.parse(args);

        if (!config.success() || config.getBoolean("help")) {
            System.out.println();
            for (Iterator errs = config.getErrorMessageIterator(); errs.hasNext();) {
                System.out.println("Error: " + errs.next());
            }
            System.out.println();
            System.out.println("Usage: java " + Main.class.getName());
            System.out.println("\t" + jsap.getUsage());
            System.out.println();
            System.out.println(jsap.getHelp());
            System.exit(0);
        }

        Database database = new Database();
        Parser parser     = new Parser(database);
        Compiler compiler = new Compiler(database);
        Writer writer = new Writer(database);

        parser.parse(config.getStringArray("inputFiles"));

        //todo: implement
//        compiler.setMinYear(config.getInt("minYear"));
//        compiler.setMaxYear(config.getInt("maxYear"));
        compiler.compile();

//        database.dump();

        writer.write(config.getString("outputPath"),
                     config.getStringArray("outputFormats"),
                     config.getBoolean("singleFile"));
    }
}
TOP

Related Classes of ch.pollet.jzic.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.