make URL argument not necessary for some switches
This commit is contained in:
@@ -19,7 +19,7 @@ import sys
|
|||||||
import argparse
|
import argparse
|
||||||
from . import config, jobs
|
from . import config, jobs
|
||||||
|
|
||||||
def parse_cmdline_options():
|
def build_cmdline_parser():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Download images from various sources')
|
description='Download images from various sources')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -50,12 +50,13 @@ def parse_cmdline_options():
|
|||||||
nargs="*", metavar="URL",
|
nargs="*", metavar="URL",
|
||||||
help="url to download images from"
|
help="url to download images from"
|
||||||
)
|
)
|
||||||
return parser.parse_args()
|
return parser
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
config.load()
|
config.load()
|
||||||
args = parse_cmdline_options()
|
parser = build_cmdline_parser()
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
for opt in args.option:
|
for opt in args.option:
|
||||||
try:
|
try:
|
||||||
@@ -68,6 +69,8 @@ def main():
|
|||||||
for module_name in extractor.modules:
|
for module_name in extractor.modules:
|
||||||
print(module_name)
|
print(module_name)
|
||||||
else:
|
else:
|
||||||
|
if not args.urls:
|
||||||
|
parser.error("the following arguments are required: URL")
|
||||||
jobtype = jobs.KeywordJob if args.keywords else jobs.DownloadJob
|
jobtype = jobs.KeywordJob if args.keywords else jobs.DownloadJob
|
||||||
for url in args.urls:
|
for url in args.urls:
|
||||||
jobtype(url).run()
|
jobtype(url).run()
|
||||||
|
|||||||
Reference in New Issue
Block a user