diff --git a/url2markdown/__main__.py b/url2markdown/__main__.py index 7b90274..7e9f0dd 100755 --- a/url2markdown/__main__.py +++ b/url2markdown/__main__.py @@ -5,12 +5,22 @@ from url2markdown.file import write_to_file from url2markdown.header import Header -def main(): - args = cli() - article = downloader(args.URL) - header = Header(article, args.topics) +def main(url, topics): + article = downloader(url) + header = Header(article, topics) write_to_file(article, header.build_header()) if __name__ == "__main__": - main() + args = cli() + if args.url: + main(args.url, args.topics) + if args.file: + with args.file as input_file: + for line in input_file: + try: + url, topics = line.split(' ') + except ValueError: + url = line + topics = [] + main(url, topics)