changeset 390:9d02187611ae

make delimeters CLI switchable
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 27 Jul 2013 20:09:49 -0700
parents 2d4dfe1dc632
children cccfe246452e
files python/tree2.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/python/tree2.py	Sat Jul 27 20:01:01 2013 -0700
+++ b/python/tree2.py	Sat Jul 27 20:09:49 2013 -0700
@@ -99,19 +99,29 @@
 
 def main(args=sys.argv[1:]):
 
+    # parse command line options
     usage = '%prog [options]'
     parser = optparse.OptionParser(usage=usage, description=__doc__)
+    parser.add_option('-a', '--ascii', dest='use_ascii',
+                      action='store_true', default=False,
+                      help="use ascii delimeters (%s)" % ascii_delimeters)
     options, args = parser.parse_args(args)
     if not args:
         args = ['.']
 
+    # sanity check
     not_directory = [arg for arg in args
                      if not os.path.isdir(arg)]
     if not_directory:
         parser.error("Not a directory: %s" % (', '.join(not_directory)))
 
+    delimeters = unicode_delimeters
+    if options.use_ascii:
+        delimeters = ascii_delimeters
+
+    # print the tree
     for arg in args:
-        print (tree(arg))
+        print (tree(arg, **delimeters))
 
 if __name__ == '__main__':
     main()