summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-03 20:52:47 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-08 00:12:07 +0100
commit27f9ce96db8b800b301ad3b21fb81355e982941a (patch)
treebf516a44edfc970bc3d64e03c603807830d4d555
parent3f2675aab119e55f958563e2fe6949192a2b976d (diff)
Allow configuration of Grok licence via dcpomatic2_cli (#2981).
-rw-r--r--src/lib/encode_cli.cc38
-rw-r--r--test/encode_cli_test.cc26
2 files changed, 63 insertions, 1 deletions
diff --git a/src/lib/encode_cli.cc b/src/lib/encode_cli.cc
index 67c82c141..7e9c25a6a 100644
--- a/src/lib/encode_cli.cc
+++ b/src/lib/encode_cli.cc
@@ -72,6 +72,10 @@ help(function <void (string)> out)
out(" make-dcp <FILM> make DCP from the given film; default if no other command is specified\n");
out(variant::insert_dcpomatic(" list-servers display a list of encoding servers that %1 can use (until Ctrl-C)\n"));
out(" dump <FILM> show a summary of the film's settings\n");
+#ifdef DCPOMATIC_GROK
+ out(" config-params list the parameters that can be set with `config`\n");
+ out(" config <PARAMETER> <VALUE> set a DCP-o-matic configuration value\n");
+#endif
out("\nOptions:\n\n");
out(variant::insert_dcpomatic(" -v, --version show %1 version\n"));
@@ -95,6 +99,7 @@ help(function <void (string)> out)
out(" --hints analyze film for hints before encoding and abort if any are found\n");
out("\ne.g.\n");
out(fmt::format("\n {} -t 4 make-dcp my_great_movie\n", program_name));
+ out(fmt::format("\n {} config grok-licence 12345ABCD\n", program_name));
out("\n");
}
@@ -374,7 +379,13 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void ()
vector<string> commands = {
"make-dcp",
"list-servers",
+#ifdef DCPOMATIC_GROK
+ "dump",
+ "config-params",
+ "config"
+#else
"dump"
+#endif
};
if (optind < argc - 1) {
@@ -387,6 +398,33 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void ()
}
}
+
+#ifdef DCPOMATIC_GROK
+ if (command == "config-params") {
+ out("Configurable parameters:\n\n");
+ out(" grok-licence licence string for using the Grok JPEG2000 encoder\n");
+ return {};
+ }
+
+ if (command == "config") {
+ if (optind < argc - 1) {
+ string const parameter = argv[optind++];
+ string const value = argv[optind++];
+ auto grok = Config::instance()->grok();
+ if (parameter == "grok-licence") {
+ grok.licence = value;
+ Config::instance()->set_grok(grok);
+ Config::instance()->write();
+ } else {
+ return fmt::format("Unrecognised configuration parameter `{}'", parameter);
+ }
+ } else {
+ return fmt::format("Missing configuration parameter: use {} config <parameter> <value>", program_name);
+ }
+ return {};
+ }
+#endif
+
if (config) {
State::override_path = *config;
}
diff --git a/test/encode_cli_test.cc b/test/encode_cli_test.cc
index d857476a6..8ee656277 100644
--- a/test/encode_cli_test.cc
+++ b/test/encode_cli_test.cc
@@ -47,8 +47,11 @@ run(vector<string> const& args, vector<string>& output)
argv[args.size()] = nullptr;
auto error = encode_cli(args.size(), argv.data(), [&output](string s) { output.push_back(s); }, []() { });
+ for (auto i: output) {
+ std::cout << "O:" << i;
+ }
if (error) {
- std::cout << *error << "\n";
+ std::cout << "E:" << *error << "\n";
}
return error;
@@ -99,3 +102,24 @@ BOOST_AUTO_TEST_CASE(encode_cli_with_explicit_encode_command_test)
BOOST_CHECK(find_in_order(output, { "Making DCP for", "Examining content", "OK", "Transcoding DCP", "OK" }));
}
+
+
+#ifdef DCPOMATIC_GROK
+BOOST_AUTO_TEST_CASE(encode_cli_set_grok_licence)
+{
+ boost::filesystem::path config = "build/encode_cli_set_grok_licence";
+ boost::filesystem::remove_all(config);
+ boost::filesystem::create_directories(config);
+ ConfigRestorer cr(config);
+
+ vector<string> output;
+ auto error = run({ "cli", "config", "grok-licence", "12345678ABC" }, output);
+ BOOST_CHECK(output.empty());
+ BOOST_CHECK(!error);
+
+ cxml::Document check("Config");
+ check.read_file(config / "2.18" / "config.xml");
+ BOOST_CHECK_EQUAL(check.node_child("Grok")->string_child("Licence"), "12345678ABC");
+}
+#endif
+