Improve _script/* root directory handling.
authorW. Trevor King <wking@drexel.edu>
Thu, 7 Oct 2010 12:39:57 +0000 (08:39 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 7 Oct 2010 12:39:57 +0000 (08:39 -0400)
_script/build.sh
_script/clean.sh
_script/html_toc.py

index b0c6dcbf3fc93416ac7651b4bb449de55b8c7de2..611e86fd864ed5ef2d279685b572d879968a7178 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/bash
 
-math.sh .
-html_toc.py .
-make_tar.sh .
+ROOT='.'
+if [ $# -gt 0 ]; then
+    ROOT="$1"
+fi
+
+math.sh "$ROOT"
+html_toc.py "$ROOT"
+make_tar.sh "$ROOT"
index 280cef8a0d7b79d24d3c14eab30e66242e895f10..73cf80632dc9a758163769c2576eb1138511726c 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/bash
 
-make_tar.sh --clean .
-html_toc.py --clean
-math.sh --clean .
+ROOT='.'
+if [ $# -gt 0 ]; then
+    ROOT="$1"
+fi
+
+make_tar.sh --clean "$ROOT"
+html_toc.py --clean "$ROOT"
+math.sh --clean "$ROOT"
index b530fad95a5f0cf0f2ddd12636e588513557828f..ee6b8ee07a8632ef3015d4fc2ccd4b4ff93b5b43 100755 (executable)
@@ -188,15 +188,17 @@ class ToCTree (object):
 
 
 if __name__ == '__main__':
-    root = '.'
-    clean = False
-    if len(sys.argv) > 1:
-        root = sys.argv[1]
-        if '--clean' in sys.argv[1:]:
-            if root == '--clean':
-                root = '.'
-            clean = True
+    import optparse
+
+    p = optparse.OptionParser(usage='%prog [options] [ROOT]')
+    p.add_option('-c', '--clean', default=False, action='store_true',
+                 help="Clean TOCs instead of building them.")
+    options,args = p.parse_args()
+
     index_file = 'index.shtml'
+    root = '.'
+    if len(args) > 0:
+        root = args[0]
 
     tree = ToCTree(path=root)
-    tree.set_tocs(clean=clean)
+    tree.set_tocs(clean=options.clean)