summaryrefslogtreecommitdiff
path: root/src/lib/kdm_cli.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-23 21:53:32 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-26 00:27:08 +0100
commit8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (patch)
tree40da87cb357e8b1c54a1464bdbac2d014640e30c /src/lib/kdm_cli.cc
parentcec6ff92aef45c687085ecfc1059004407c18c57 (diff)
Replace String::compose with fmt::format().
Diffstat (limited to 'src/lib/kdm_cli.cc')
-rw-r--r--src/lib/kdm_cli.cc43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc
index 20cbf33e6..0d0c6a8b8 100644
--- a/src/lib/kdm_cli.cc
+++ b/src/lib/kdm_cli.cc
@@ -39,6 +39,7 @@
#include <dcp/decrypted_kdm.h>
#include <dcp/encrypted_kdm.h>
#include <dcp/filesystem.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
#include <getopt.h>
@@ -62,13 +63,13 @@ using namespace dcpomatic;
static void
help (std::function<void (string)> out)
{
- out (String::compose("Syntax: %1 [OPTION] [COMMAND] <FILM|CPL-ID|DKDM>", program_name));
+ out (fmt::format("Syntax: {} [OPTION] [COMMAND] <FILM|CPL-ID|DKDM>", program_name));
out ("Commands:");
out ("create create KDMs; default if no other command is specified");
- out (variant::insert_dcpomatic("list-cinemas list known cinemas from %1 settings"));
- out (variant::insert_dcpomatic("list-dkdm-cpls list CPLs for which %1 has DKDMs"));
- out (variant::insert_dcpomatic("add-dkdm add DKDM to %1's list"));
- out (variant::insert_dcpomatic("dump-decryption-certificate write the %1 KDM decryption certificate to the console"));
+ out (variant::insert_dcpomatic("list-cinemas list known cinemas from {} settings"));
+ out (variant::insert_dcpomatic("list-dkdm-cpls list CPLs for which {} has DKDMs"));
+ out (variant::insert_dcpomatic("add-dkdm add DKDM to {}'s list"));
+ out (variant::insert_dcpomatic("dump-decryption-certificate write the {} KDM decryption certificate to the console"));
out (" -h, --help show this help");
out (" -o, --output <path> output file or directory");
out (" -K, --filename-format <format> filename format for KDMs");
@@ -87,17 +88,17 @@ help (std::function<void (string)> out)
out (" -C, --projector-certificate <file> file containing projector certificate");
out (" -T, --trusted-device-certificate <file> file containing a trusted device's certificate");
out (" --decryption-key <file> file containing the private key which can decrypt the given DKDM");
- out (variant::insert_dcpomatic(" (%1's configured private key will be used otherwise)"));
+ out (variant::insert_dcpomatic(" ({}'s configured private key will be used otherwise)"));
out (" --cinemas-file <file> use the given file as a list of cinemas instead of the current configuration");
out ("");
- out (variant::insert_dcpomatic("CPL-ID must be the ID of a CPL that is mentioned in %1's DKDM list."));
+ out (variant::insert_dcpomatic("CPL-ID must be the ID of a CPL that is mentioned in {}'s DKDM list."));
out ("");
out ("For example:");
out ("");
out ("Create KDMs for my_great_movie to play in all of Fred's Cinema's screens for the next two weeks and zip them up.");
- out (variant::insert_dcpomatic("(Fred's Cinema must have been set up in %1's KDM window)"));
+ out (variant::insert_dcpomatic("(Fred's Cinema must have been set up in {}'s KDM window)"));
out ("");
- out (String::compose("\t%1 -c \"Fred's Cinema\" -f now -d \"2 weeks\" -z my_great_movie", program_name));
+ out (fmt::format("\t{} -c \"Fred's Cinema\" -f now -d \"2 weeks\" -z my_great_movie", program_name));
}
@@ -105,7 +106,7 @@ class KDMCLIError : public std::runtime_error
{
public:
KDMCLIError (std::string message)
- : std::runtime_error (String::compose("%1: %2", program_name, message).c_str())
+ : std::runtime_error(fmt::format("{}: {}", program_name, message).c_str())
{}
};
@@ -119,7 +120,7 @@ duration_from_string (string d)
string const unit (unit_buf);
if (N == 0) {
- throw KDMCLIError (String::compose("could not understand duration \"%1\"", d));
+ throw KDMCLIError(fmt::format("could not understand duration \"{}\"", d));
}
if (unit == "year" || unit == "years") {
@@ -132,7 +133,7 @@ duration_from_string (string d)
return boost::posix_time::time_duration (N, 0, 0, 0);
}
- throw KDMCLIError (String::compose("could not understand duration \"%1\"", d));
+ throw KDMCLIError(fmt::format("could not understand duration \"{}\"", d));
}
@@ -165,7 +166,7 @@ write_files (
);
if (verbose) {
- out (String::compose("Wrote %1 ZIP files to %2", N, output));
+ out(fmt::format("Wrote {} ZIP files to {}", N, output.string()));
}
} else {
int const N = write_files (
@@ -174,7 +175,7 @@ write_files (
);
if (verbose) {
- out (String::compose("Wrote %1 KDM files to %2", N, output));
+ out(fmt::format("Wrote {} KDM files to {}", N, output.string()));
}
}
}
@@ -219,10 +220,10 @@ from_film (
film = make_shared<Film>(film_dir);
film->read_metadata ();
if (verbose) {
- out (String::compose("Read film %1", film->name()));
+ out(fmt::format("Read film {}", film->name()));
}
} catch (std::exception& e) {
- throw KDMCLIError (String::compose("error reading film \"%1\" (%2)", film_dir.string(), e.what()));
+ throw KDMCLIError(fmt::format("error reading film \"{}\" ({})", film_dir.string(), e.what()));
}
/* XXX: allow specification of this */
@@ -283,7 +284,7 @@ from_film (
send_emails ({kdms}, container_name_format, filename_format, film->dcp_name(), {});
}
} catch (FileError& e) {
- throw KDMCLIError (String::compose("%1 (%2)", e.what(), e.file().string()));
+ throw KDMCLIError(fmt::format("{} ({})", e.what(), e.file().string()));
}
}
@@ -410,7 +411,7 @@ from_dkdm (
send_emails ({kdms}, container_name_format, filename_format, dkdm.annotation_text().get_value_or(""), {});
}
} catch (FileError& e) {
- throw KDMCLIError (String::compose("%1 (%2)", e.what(), e.file().string()));
+ throw KDMCLIError(fmt::format("{} ({})", e.what(), e.file().string()));
}
}
@@ -625,7 +626,7 @@ try
}
if (std::find(commands.begin(), commands.end(), command) == commands.end()) {
- throw KDMCLIError(String::compose("Unrecognised command %1", command));
+ throw KDMCLIError(fmt::format("Unrecognised command {}", command));
}
if (cinemas_file) {
@@ -646,7 +647,7 @@ try
if (command == "list-cinemas") {
CinemaList cinemas;
for (auto const& cinema: cinemas.cinemas()) {
- out(String::compose("%1 (%2)", cinema.second.name, Email::address_list(cinema.second.emails)));
+ out(fmt::format("{} ({})", cinema.second.name, Email::address_list(cinema.second.emails)));
}
return {};
}
@@ -714,7 +715,7 @@ try
}
if (verbose) {
- out(String::compose("Making KDMs valid from %1 to %2", valid_from->as_string(), valid_to->as_string()));
+ out(fmt::format("Making KDMs valid from {} to {}", valid_from->as_string(), valid_to->as_string()));
}
string const thing = argv[optind];