add \Box
[wix.git] / src / ScalaHelper.java
index 85065e2..520a979 100644 (file)
@@ -48,20 +48,27 @@ public class ScalaHelper {
     }
 
     public static void main(String[] argv, TreeToString t2s) throws Throwable {
     }
 
     public static void main(String[] argv, TreeToString t2s) throws Throwable {
-        if (argv.length != 2) {
-            System.out.println("usage: java -jar wix.jar [-v] <indir> <outdir>");
+        if (argv.length == 0) {
+            System.out.println("usage: java -jar wix.jar [-v] [-f] <indir> <outdir>");
             // FIXME: implement this
             // FIXME: implement this
-            System.out.println("     | java -jar wix.jar [-v] <infile>.wix");
+            System.out.println("     | java -jar wix.jar [-v] [-f] <infile>.wix");
             System.out.println("");
             // FIXME: implement these
             System.out.println("   -v   print text as it is parsed (sbp.verbose=true)");
             System.out.println("   -vv  like -v, but also dump parse tree");
             System.out.println("   -vvv like -vv, but also dump wix tree");
             System.out.println("");
             // FIXME: implement these
             System.out.println("   -v   print text as it is parsed (sbp.verbose=true)");
             System.out.println("   -vv  like -v, but also dump parse tree");
             System.out.println("   -vvv like -vv, but also dump wix tree");
+            System.out.println("   -f   recompile documents regardless of last-modified-time");
             System.exit(-1);
             return;
         }
             System.exit(-1);
             return;
         }
-        File indir = new File(argv[0]);
-        File outdir = new File(argv[1]);
+        int i = 0;
+        for(;; i++) {
+            if (argv[i].equals("-v")) { verbose = true; continue; }
+            if (argv[i].equals("-f")) { force = true; continue; }
+            break;
+        }
+        File indir = new File(argv[i]);
+        File outdir = new File(argv[i+1]);
         if (!indir.isDirectory()) {
             process(new File(indir.getParent()), indir.getName(), outdir, t2s);
         } else {
         if (!indir.isDirectory()) {
             process(new File(indir.getParent()), indir.getName(), outdir, t2s);
         } else {
@@ -69,6 +76,9 @@ public class ScalaHelper {
         }
     }
 
         }
     }
 
+    private static boolean verbose = false;
+    private static boolean force   = false;
+
     private static void process(File indir, String suffix, File outdir, TreeToString t2s) throws Throwable {
         File f = new File(indir.getAbsolutePath()+File.separatorChar+suffix);
         //System.out.println(f+" "+indir + " " + suffix + " " + outdir);
     private static void process(File indir, String suffix, File outdir, TreeToString t2s) throws Throwable {
         File f = new File(indir.getAbsolutePath()+File.separatorChar+suffix);
         //System.out.println(f+" "+indir + " " + suffix + " " + outdir);
@@ -112,7 +122,7 @@ public class ScalaHelper {
             //System.out.println();
             String outPath = outdir.getAbsolutePath()+File.separatorChar+suffix;
             outPath = outPath.substring(0, outPath.length()-".wix".length())+".html";
             //System.out.println();
             String outPath = outdir.getAbsolutePath()+File.separatorChar+suffix;
             outPath = outPath.substring(0, outPath.length()-".wix".length())+".html";
-            if (new File(outPath).exists() && new File(outPath).lastModified() > f.lastModified()) return;
+            if (new File(outPath).exists() && new File(outPath).lastModified() > f.lastModified() && !force) return;
 
             Tree tree = parseFile(f.getAbsolutePath());
             String ret = t2s.run(tree);
 
             Tree tree = parseFile(f.getAbsolutePath());
             String ret = t2s.run(tree);