From: Adam Megacz Date: Mon, 24 Jan 2011 00:15:43 +0000 (-0800) Subject: add -f option X-Git-Url: http://git.megacz.com/?p=wix.git;a=commitdiff_plain;h=ab26ff591fbbaf202c3d95af6c50df747513d8ea add -f option --- diff --git a/Makefile b/Makefile index a1373e3..cbf8c61 100644 --- a/Makefile +++ b/Makefile @@ -18,17 +18,19 @@ java = java $(jvmargs) $(profile) -cp src:$(ghclibs):$(sbp)/edu.berkeley.sbp.ja scala = JAVA_OPTS="$(jvmargs)" scala wix = $(java) HaskellHelper +args = install: wix.jar aklog research.cs.berkeley.edu || true - $(scala) -cp wix.jar:lib/edu.berkeley.sbp.jar Main ~/docs/wix/src/ ~/docs/wix/dest/ - + $(scala) -cp wix.jar:lib/edu.berkeley.sbp.jar Main $(args) ~/docs/wix/src/ ~/docs/wix/dest/ # --delete disabled until I can keep it from clobbering GArrow.v rsync -arL --rsync-path=/usr/sww/bin/rsync \ --progress --verbose \ ~/docs/wix/dest/cs.berkeley.edu/ \ login.eecs.berkeley.edu:public_html/ +force:; make install args='-f' + docs: $(wix) xt2/docs/ ~/docs/ 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);