summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-03 22:10:56 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-08 00:12:07 +0100
commit641f5f2f61b77d79cb1e8c737cda0766b1ee2de8 (patch)
tree6195f00f8e48e64dc8765d62604a9d8056191de0
parent27f9ce96db8b800b301ad3b21fb81355e982941a (diff)
Support some more grok configuration in the dcpomatic2_cli.
-rw-r--r--src/lib/encode_cli.cc18
-rw-r--r--test/encode_cli_test.cc38
2 files changed, 53 insertions, 3 deletions
diff --git a/src/lib/encode_cli.cc b/src/lib/encode_cli.cc
index 7e9c25a6a..f28b93421 100644
--- a/src/lib/encode_cli.cc
+++ b/src/lib/encode_cli.cc
@@ -402,7 +402,9 @@ 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");
+ out(" grok-licence licence string for using the Grok JPEG2000 encoder\n");
+ out(" grok-enable 1 to enable the Grok encoder, 0 to disable it\n");
+ out(" grok-binary-location directory containing Grok binaries\n");
return {};
}
@@ -413,11 +415,21 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void ()
auto grok = Config::instance()->grok();
if (parameter == "grok-licence") {
grok.licence = value;
- Config::instance()->set_grok(grok);
- Config::instance()->write();
+ } else if (parameter == "grok-enable") {
+ if (value == "1") {
+ grok.enable = true;
+ } else if (value == "0") {
+ grok.enable = false;
+ } else {
+ return fmt::format("Invalid value {} for grok-enable (use 1 to enable, 0 to disable)", value);
+ }
+ } else if (parameter == "grok-binary-location") {
+ grok.binary_location = value;
} else {
return fmt::format("Unrecognised configuration parameter `{}'", parameter);
}
+ Config::instance()->set_grok(grok);
+ Config::instance()->write();
} else {
return fmt::format("Missing configuration parameter: use {} config <parameter> <value>", program_name);
}
diff --git a/test/encode_cli_test.cc b/test/encode_cli_test.cc
index 8ee656277..0a0a17e3a 100644
--- a/test/encode_cli_test.cc
+++ b/test/encode_cli_test.cc
@@ -121,5 +121,43 @@ BOOST_AUTO_TEST_CASE(encode_cli_set_grok_licence)
check.read_file(config / "2.18" / "config.xml");
BOOST_CHECK_EQUAL(check.node_child("Grok")->string_child("Licence"), "12345678ABC");
}
+
+
+BOOST_AUTO_TEST_CASE(encode_cli_enable_grok)
+{
+ boost::filesystem::path config = "build/encode_cli_enable_grok";
+ boost::filesystem::remove_all(config);
+ boost::filesystem::create_directories(config);
+ ConfigRestorer cr(config);
+
+ for (auto value: vector<string>{ "1", "0"}) {
+ vector<string> output;
+ auto error = run({ "cli", "config", "grok-enable", value }, 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("Enable"), value);
+ }
+}
+
+
+BOOST_AUTO_TEST_CASE(encode_cli_set_grok_binary_location)
+{
+ boost::filesystem::path config = "build/encode_cli_set_grok_binary_location";
+ boost::filesystem::remove_all(config);
+ boost::filesystem::create_directories(config);
+ ConfigRestorer cr(config);
+
+ vector<string> output;
+ auto error = run({ "cli", "config", "grok-binary-location", "foo/bar/baz" }, 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("BinaryLocation"), "foo/bar/baz");
+}
#endif