# HG changeset patch # User Mattijs Hoitink # Date 1329243450 -3600 # Node ID afba81586593006b9b47194a4017fbbafb9de1e0 # Parent 5e48c681a0707ec6b72afcf2f3ff6dca47b096b6 Added argument parsing to d d takes two optional arguments to pass in the source and target directories. The bin/dc executable has been removed. diff -r 5e48c681a070 -r afba81586593 bin/d --- a/bin/d Tue Feb 07 21:10:22 2012 +0100 +++ b/bin/d Tue Feb 14 19:17:30 2012 +0100 @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, os +import sys, os, argparse # Ugly hack so I can code in peace. try: @@ -10,9 +10,13 @@ from d.base import render_files if __name__ == '__main__': - if len(sys.argv) > 1: - sys.stderr.write("d doesn't take any arguments.\n") - sys.stderr.write("Just cd into your docs/ directory, run d, and move on.\n") - sys.exit(1) - else: - render_files('.', './build') + + # Argument parser + parser = argparse.ArgumentParser(description='Markdown files to documentation. Run and get on with your life.') + parser.add_argument('-s', dest='source', default='.', help='Documentation source', metavar='SOURCE') + parser.add_argument('-t', dest='target', default='./build', help='Documentation output target', metavar='TARGET') + + args = parser.parse_args() + + # Render with arguments + render_files(args.source, args.target) diff -r 5e48c681a070 -r afba81586593 bin/dc --- a/bin/dc Tue Feb 07 21:10:22 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -# Configurable version of 'd'. This executable takes two arguments: source and destsination -# - -import sys, os - -# Ugly hack so I can code in peace. -try: - from d.base import render_files -except ImportError: - sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..'))) - from d.base import render_files - -if __name__ == '__main__': - if len(sys.argv) < 3: - sys.stderr.write("dc requires 2 arguments: dc SOURCE DESTINATION\n") - sys.exit(1) - else: - render_files(sys.argv[1], sys.argv[2])