move the main decision tree to __main__

This commit is contained in:
Andreas Zweili 2020-10-13 22:47:11 +02:00
parent 5f0de1e8e2
commit 89806e0be2
1 changed files with 15 additions and 5 deletions

View File

@ -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)