[options] add '--Print' command-line option

This commit is contained in:
Mike Fährmann
2025-06-20 16:32:48 +02:00
parent 9e56d81292
commit 8a35863e86
2 changed files with 14 additions and 1 deletions

View File

@@ -51,6 +51,8 @@
-N, --print [EVENT:]FORMAT Write FORMAT during EVENT (default 'prepare')
to standard output. Examples: 'id' or
'post:{md5[:8]}'
--Print [EVENT:]FORMAT Like --print, but also sets --no-download,
--no-skip, and disables other output to stdout
--print-to-file [EVENT:]FORMAT FILE
Append FORMAT during EVENT to FILE
--list-modules Print a list of available extractor modules

View File

@@ -156,7 +156,11 @@ class UgoiraAction(argparse.Action):
class PrintAction(argparse.Action):
def __call__(self, parser, namespace, value, option_string=None):
if self.const:
filename = self.const
if self.const == "+":
namespace.options.append(((), "skip", False))
namespace.options.append(((), "download", False))
namespace.options.append((("output",), "mode", False))
filename = "-"
base = None
mode = "w"
else:
@@ -397,6 +401,13 @@ def build_parser():
help=("Write FORMAT during EVENT (default 'prepare') to standard "
"output. Examples: 'id' or 'post:{md5[:8]}'"),
)
output.add_argument(
"--Print",
dest="postprocessors", metavar="[EVENT:]FORMAT",
action=PrintAction, const="+",
help=("Like --print, but also sets --no-download, --no-skip, "
"and disables other output to stdout"),
)
output.add_argument(
"--print-to-file",
dest="postprocessors", metavar="[EVENT:]FORMAT FILE",