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)