summaryrefslogtreecommitdiffstats
path: root/gallery_dl/option.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/option.py')
-rw-r--r--gallery_dl/option.py69
1 files changed, 43 insertions, 26 deletions
diff --git a/gallery_dl/option.py b/gallery_dl/option.py
index 213cd2d..aad307f 100644
--- a/gallery_dl/option.py
+++ b/gallery_dl/option.py
@@ -10,9 +10,8 @@
import argparse
import logging
-import json
import sys
-from . import job, version
+from . import job, util, version
class ConfigAction(argparse.Action):
@@ -62,24 +61,21 @@ class OptionAction(argparse.Action):
class Formatter(argparse.HelpFormatter):
"""Custom HelpFormatter class to customize help output"""
- def __init__(self, *args, **kwargs):
- super().__init__(max_help_position=30, *args, **kwargs)
+ def __init__(self, prog):
+ argparse.HelpFormatter.__init__(self, prog, max_help_position=30)
- def _format_action_invocation(self, action):
- opts = action.option_strings[:]
- if opts:
- if action.nargs != 0:
- args_string = self._format_args(action, "ARG")
- opts[-1] += " " + args_string
- return ', '.join(opts)
- else:
- return self._metavar_formatter(action, action.dest)(1)[0]
+ def _format_action_invocation(self, action, join=", ".join):
+ opts = action.option_strings
+ if action.metavar:
+ opts = opts.copy()
+ opts[-1] += " " + action.metavar
+ return join(opts)
def _parse_option(opt):
key, _, value = opt.partition("=")
try:
- value = json.loads(value)
+ value = util.json_loads(value)
except ValueError:
pass
return key, value
@@ -111,6 +107,12 @@ def build_parser():
"More than one --input-file can be specified"),
)
general.add_argument(
+ "-f", "--filename",
+ dest="filename", metavar="FORMAT",
+ help=("Filename format string for downloaded files "
+ "('/O' for \"original\" filenames)"),
+ )
+ general.add_argument(
"-d", "--destination",
dest="base-directory", metavar="PATH", action=ConfigAction,
help="Target location for file downloads",
@@ -121,10 +123,9 @@ def build_parser():
help="Exact location for file downloads",
)
general.add_argument(
- "-f", "--filename",
- dest="filename", metavar="FORMAT",
- help=("Filename format string for downloaded files "
- "('/O' for \"original\" filenames)"),
+ "-X", "--extractors",
+ dest="extractor_sources", metavar="PATH", action="append",
+ help="Load external extractors from PATH",
)
general.add_argument(
"--proxy",
@@ -320,25 +321,41 @@ def build_parser():
configuration = parser.add_argument_group("Configuration Options")
configuration.add_argument(
+ "-o", "--option",
+ dest="options", metavar="KEY=VALUE", action=ParseAction, default=[],
+ help=("Additional options. "
+ "Example: -o browser=firefox") ,
+ )
+ configuration.add_argument(
"-c", "--config",
- dest="cfgfiles", metavar="FILE", action="append",
+ dest="configs_json", metavar="FILE", action="append",
help="Additional configuration files",
)
configuration.add_argument(
"--config-yaml",
- dest="yamlfiles", metavar="FILE", action="append",
- help=argparse.SUPPRESS,
+ dest="configs_yaml", metavar="FILE", action="append",
+ help="Additional configuration files in YAML format",
)
configuration.add_argument(
- "-o", "--option",
- dest="options", metavar="OPT", action=ParseAction, default=[],
- help="Additional '<key>=<value>' option values",
+ "--config-toml",
+ dest="configs_toml", metavar="FILE", action="append",
+ help="Additional configuration files in TOML format",
)
configuration.add_argument(
- "--ignore-config",
- dest="load_config", action="store_false",
+ "--config-create",
+ dest="config_init", action="store_true",
+ help="Create a basic configuration file",
+ )
+ configuration.add_argument(
+ "--config-ignore",
+ dest="config_load", action="store_false",
help="Do not read default configuration files",
)
+ configuration.add_argument(
+ "--ignore-config",
+ dest="config_load", action="store_false",
+ help=argparse.SUPPRESS,
+ )
authentication = parser.add_argument_group("Authentication Options")
authentication.add_argument(