# HG changeset patch # User Jeff Hammel # Date 1404418999 25200 # Node ID 56fa70e2e2399d69c01a4e28a4317a237b9262f5 # Parent 8cf9a26b9aaaece7443fa240bf3c9fed26dbc626 STUB: textshaper/url2txt.py diff -r 8cf9a26b9aaa -r 56fa70e2e239 textshaper/url2txt.py --- a/textshaper/url2txt.py Mon May 12 10:29:06 2014 -0700 +++ b/textshaper/url2txt.py Thu Jul 03 13:23:19 2014 -0700 @@ -6,6 +6,7 @@ xclip -o | sed 's/_//' | sed 's/.html//' """ +import argparse import sys def url2txt(url): @@ -21,8 +22,16 @@ def main(args=sys.argv[1:]): """CLI""" - for arg in args: - print url2txt(arg) + + # parse command line + parser = argparse.ArgumentParser(description=__doc__) + parser.add_option('urls', metavar='url', nargs='+', + help="URLs to convert") + options = parser.parse_args(args) + + # convert urls + for url in options.urls: + print (url2txt(url)) if __name__ == '__main__':