Mercurial > hg > TextShaper
changeset 38:56fa70e2e239
STUB: textshaper/url2txt.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 03 Jul 2014 13:23:19 -0700 |
parents | 8cf9a26b9aaa |
children | 986f8a20c234 |
files | textshaper/url2txt.py |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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__':