# HG changeset patch # User Jeff Hammel # Date 1393143979 28800 # Node ID 70dde00a4df026114a91b721ba8e0ac4b24bd4c9 # Parent df52326aa08d3558e21a023d697deef591c6ac95 selectable, albeit single, input diff -r df52326aa08d -r 70dde00a4df0 textshaper/main.py --- a/textshaper/main.py Sat Feb 22 22:49:18 2014 -0800 +++ b/textshaper/main.py Sun Feb 23 00:26:19 2014 -0800 @@ -12,6 +12,7 @@ import time from which import which + def info(content): """gathers info about the content and returns a dict""" @@ -31,7 +32,11 @@ for key in keys])) def add_options(parser): - """add options to the OptionParser instance""" + """add options to the parser instance""" + + parser.add_option('-f', '--file', dest='input', + type=argparse.FileType('r'), default=sys.stdin, + help="file to read from [DEFAULT: stdin]") if which('xclip'): # TODO: support e.g. xsel or python native parser.add_option('-c', '--clip', '--copy', dest='copy_to_clipboard', @@ -47,7 +52,7 @@ options = parser.parse_args(args) # read from stdin - content = sys.stdin.read() + content = options.read() # print formatted content display(content)