put the URL and file command in a mutual exclusive group

This commit is contained in:
Andreas Zweili 2020-10-13 22:15:49 +02:00
parent f2a13861f8
commit 68782d1d22
1 changed files with 7 additions and 4 deletions

View File

@ -3,10 +3,13 @@ import argparse
def cli(): def cli():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("URL", group = parser.add_mutually_exclusive_group(required=True)
help="The URL of the article to convert to Markdown.", group.add_argument('--file',
type=str) type=argparse.FileType('r'),
parser.add_argument("--topics", help="A list of comma separated topics.") help="A file containing one URL per line.")
group.add_argument('--url',
help="The URL of the article to convert to Markdown.",
type=str)
parser.add_argument("--topics", help="A list of comma separated topics e.g. 'foo,bar'.") parser.add_argument("--topics", help="A list of comma separated topics e.g. 'foo,bar'.")
return parser.parse_args() return parser.parse_args()