package loglang;

import static loglang.misc.ArgsParser.*;
import loglang.misc.ArgsParser;

/**
 * Created by skgchxngsxyz-osx on 15/08/10.
 */
public class Main {
    private static String scriptFileName = null;
    private static String inputFileName = null;

    public static void main(String[] args) {
        ArgsParser parser = new ArgsParser();

        parser.addOption("s", "script", HAS_ARG | REQUIRE,
                "specify script file name",
                (a) -> scriptFileName = a.get());
        parser.addOption("i", "input", HAS_ARG | REQUIRE,
                "specify intput file name",
                (a) -> inputFileName = a.get());
        parser.addOption("h", "help", IGNORE_REST,
                "show this help message",
                (a) -> { parser.printHelp(System.out); System.exit(0); });

        try {
            parser.parse(args);
        } catch(IllegalArgumentException e) {
            System.err.println(e.getMessage());
            parser.printHelp(System.err);
            System.exit(1);
        }

        Loglang ll = new LoglangFactory().newLoglang(scriptFileName);
        ll.invoke(inputFileName);
    }
}

@@ -253,16 +253,57 @@
  = null;
+%0A    private static boolean time = false;
 %0A%0A    pu
@@ -503,27 +503,25 @@
             
-(a)
+a
  -%3E scriptFi
@@ -653,27 +653,25 @@
             
-(a)
+a
  -%3E inputFil
@@ -801,11 +801,9 @@
     
-(a)
+a
  -%3E 
@@ -853,16 +853,131 @@
 (0); %7D);
+%0A        parser.addOption(%22t%22, %22time%22, 0,%0A                %22show execution time%22,%0A                a -%3E time = true);
 %0A%0A      
@@ -1273,31 +1273,356 @@
     
-ll.invoke(inputFileName
+if(time) %7B%0A            time(ll);%0A        %7D else %7B%0A            ll.invoke(inputFileName);%0A        %7D%0A    %7D%0A%0A    private static void time(Loglang ll) %7B%0A        long start = System.currentTimeMillis();%0A        ll.invoke(inputFileName);%0A        long stop = System.currentTimeMillis();%0A        System.out.println(%22execution time: %22 + (stop - start) + %22ms%22
 );%0A 

add time option