From 68782d1d220b5d48e6905b327fb697becc79b4cd Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 13 Oct 2020 22:15:49 +0200 Subject: [PATCH] put the URL and file command in a mutual exclusive group --- url2markdown/cli.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/url2markdown/cli.py b/url2markdown/cli.py index c1e0d00..2a1ecd0 100644 --- a/url2markdown/cli.py +++ b/url2markdown/cli.py @@ -3,10 +3,13 @@ import argparse def cli(): parser = argparse.ArgumentParser() - parser.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.") + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('--file', + type=argparse.FileType('r'), + 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'.") return parser.parse_args()