# HG changeset patch # User Jeff Hammel # Date 1393196177 28800 # Node ID 929a5e97af3edc9fb5c353a11d811c57221703ca # Parent 23616399f36c6e3137085f62e189340dc7682689 prestrip text unless specified diff -r 23616399f36c -r 929a5e97af3e textshaper/main.py --- a/textshaper/main.py Sun Feb 23 14:48:40 2014 -0800 +++ b/textshaper/main.py Sun Feb 23 14:56:17 2014 -0800 @@ -37,6 +37,9 @@ parser.add_argument('-f', '--file', dest='input', type=argparse.FileType('r'), default=sys.stdin, help="file to read from [DEFAULT: stdin]") + parser.add_argument('-n', '--no-strip', dest='strip', + action='store_false', default=True, + help="do not strip whitespace before processing") if which('xclip'): # TODO: support e.g. xsel or python native parser.add_argument('-c', '--clip', '--copy', dest='copy_to_clipboard', @@ -47,6 +50,8 @@ def main(args=sys.argv[1:]): + # TODO: read ~/.textshaper + # parse command line options parser = argparse.ArgumentParser(description=__doc__) add_options(parser) @@ -55,6 +60,10 @@ # read input content = options.input.read() + # pre-process output + if options.strip: + content = content.strip() + # print formatted content display(content)