diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 9dde722..3920f3c 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -109,7 +109,7 @@ def register_runtime(parser: settngs.Manager) -> None: "--metadata", default=GenericMetadata(), type=parse_metadata_from_string, - help="""Explicitly define some tags to be used in YAML syntax. e.g.:\n"series: Plastic Man, publisher: Quality Comics, year: "\n"series: 'Kickers, Inc.', issue: '1', year: 1986"\nIf you want to erase a tag leave the value blank.\nSome names that can be used: series, issue, issue_count, year,\npublisher, title\n\n""", + help="""Explicitly define some tags to be used in YAML syntax. Use @file.yaml to read from a file. e.g.:\n"series: Plastic Man, publisher: Quality Comics, year: "\n"series: 'Kickers, Inc.', issue: '1', year: 1986"\nIf you want to erase a tag leave the value blank.\nSome names that can be used: series, issue, issue_count, year,\npublisher, title\n\n""", file=False, ) parser.add_setting( diff --git a/comictaggerlib/ctsettings/types.py b/comictaggerlib/ctsettings/types.py index 27dbbf3..f693a0d 100644 --- a/comictaggerlib/ctsettings/types.py +++ b/comictaggerlib/ctsettings/types.py @@ -203,6 +203,11 @@ def parse_metadata_from_string(mdstr: str) -> GenericMetadata: if not mdstr: return md + if mdstr[0] == "@": + p = pathlib.Path(mdstr[1:]) + if not p.is_file(): + raise argparse.ArgumentTypeError("Invalid filepath") + mdstr = p.read_text() if mdstr[0] != "{": mdstr = "{" + mdstr + "}"