X-Git-Url: http://git.megacz.com/?p=wix.git;a=blobdiff_plain;f=src%2FScalaHelper.java;h=520a979be787010ab23e30db4bf572ddc011340d;hp=85065e259f59bc2e6c5dd82feb7fb827a00242b1;hb=ab26ff591fbbaf202c3d95af6c50df747513d8ea;hpb=d130478a35696e78eb2fd6e55b09e6885a9c2a23 diff --git a/src/ScalaHelper.java b/src/ScalaHelper.java index 85065e2..520a979 100644 --- a/src/ScalaHelper.java +++ b/src/ScalaHelper.java @@ -48,20 +48,27 @@ public class ScalaHelper { } public static void main(String[] argv, TreeToString t2s) throws Throwable { - if (argv.length != 2) { - System.out.println("usage: java -jar wix.jar [-v] "); + if (argv.length == 0) { + System.out.println("usage: java -jar wix.jar [-v] [-f] "); // FIXME: implement this - System.out.println(" | java -jar wix.jar [-v] .wix"); + System.out.println(" | java -jar wix.jar [-v] [-f] .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(" -f recompile documents regardless of last-modified-time"); 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 { @@ -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); @@ -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"; - 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);