Mercurial > hg > TextShaper
diff textshaper/main.py @ 22:586631375670
STUB: README.txt textshaper/main.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 23 Feb 2014 10:10:45 -0800 |
parents | 70dde00a4df0 |
children | 929a5e97af3e |
line wrap: on
line diff
--- a/textshaper/main.py Sun Feb 23 00:45:06 2014 -0800 +++ b/textshaper/main.py Sun Feb 23 10:10:45 2014 -0800 @@ -34,25 +34,26 @@ def add_options(parser): """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]") + parser.add_argument('-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', - action='store_true', default=False, - help="copy to clipboard") + parser.add_argument('-c', '--clip', '--copy', dest='copy_to_clipboard', + action='store_true', default=False, + help="copy to clipboard") def main(args=sys.argv[1:]): # parse command line options - parser = argparse.ArgumentParser(description=__doc__, formatter=PlainDescriptionFormatter()) + parser = argparse.ArgumentParser(description=__doc__) + add_options(parser) options = parser.parse_args(args) - # read from stdin - content = options.read() + # read input + content = options.input.read() # print formatted content display(content)