From 0cdb390a035f8bb6d3a17633f791a78cf835143c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 22 Mar 2024 20:39:38 +0100 Subject: Add add-dkdm command to add DKDMs to DCP-o-matic's internal list from the CLI. --- src/lib/kdm_cli.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/lib/kdm_cli.cc') diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index f63fd2a55..651ba8e26 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -62,6 +62,7 @@ help (std::function out) out ("create create KDMs; default if no other command is specified"); out ("list-cinemas list known cinemas from DCP-o-matic settings"); out ("list-dkdm-cpls list CPLs for which DCP-o-matic has DKDMs"); + out ("add-dkdm add DKDM to DCP-o-matic's list"); out (" -h, --help show this help"); out (" -o, --output output file or directory"); out (" -K, --filename-format filename format for KDMs"); @@ -594,7 +595,8 @@ try vector commands = { "create", "list-cinemas", - "list-dkdm-cpls" + "list-dkdm-cpls", + "add-dkdm" }; if (optind < argc - 1) { @@ -603,7 +605,7 @@ try } else if (optind < argc) { /* Look for a valid command, hoping that it's not the name of the KDM / CPL / whatever */ if (std::find(commands.begin(), commands.end(), argv[optind]) != commands.end()) { - command = argv[optind]; + command = argv[optind++]; } } @@ -638,6 +640,17 @@ try return {}; } + if (optind >= argc) { + throw KDMCLIError("no film, CPL ID or DKDM specified"); + } + + if (command == "add-dkdm") { + auto dkdms = Config::instance()->dkdms(); + dkdms->add(make_shared(dcp::EncryptedKDM(dcp::file_to_string(argv[optind])))); + Config::instance()->write_config(); + return {}; + } + if (!duration_string && !valid_to) { throw KDMCLIError ("you must specify a --valid-duration or --valid-to"); } @@ -646,10 +659,6 @@ try throw KDMCLIError ("you must specify --valid-from"); } - if (optind >= argc) { - throw KDMCLIError ("no film, CPL ID or DKDM specified"); - } - if (screens.empty()) { if (!cinema_name) { throw KDMCLIError ("you must specify either a cinema or one or more screens using certificate files"); -- cgit v1.2.3