From: W. Trevor King Date: Thu, 7 Oct 2010 12:39:57 +0000 (-0400) Subject: Improve _script/* root directory handling. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fe009bfb6571cf80ed917942030f920471b5d6c5;p=parallel_computing.git Improve _script/* root directory handling. --- diff --git a/_script/build.sh b/_script/build.sh index b0c6dcb..611e86f 100755 --- a/_script/build.sh +++ b/_script/build.sh @@ -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" diff --git a/_script/clean.sh b/_script/clean.sh index 280cef8..73cf806 100755 --- a/_script/clean.sh +++ b/_script/clean.sh @@ -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" diff --git a/_script/html_toc.py b/_script/html_toc.py index b530fad..ee6b8ee 100755 --- a/_script/html_toc.py +++ b/_script/html_toc.py @@ -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)