diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-02-25 23:39:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-03-03 01:25:43 +0100 |
| commit | 9bc613b81ac9f818b0eb4d190d7f6d0ef3cbcd78 (patch) | |
| tree | e11b15ede30c641a0b24f884be2bb32b2939630e | |
| parent | 61614dcb37ce1bc3cf3fc2915ccac741cfef68e5 (diff) | |
Add --hints option to dcpomatic2_cli (#2468).
| -rw-r--r-- | src/tools/dcpomatic_cli.cc | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 502446a33..f4359ce86 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -28,6 +28,7 @@ #include "lib/ffmpeg_encoder.h" #include "lib/film.h" #include "lib/filter.h" +#include "lib/hints.h" #include "lib/job_manager.h" #include "lib/json_server.h" #include "lib/log.h" @@ -77,6 +78,7 @@ help (string n) << " --no-check don't check project's content files for changes before making the DCP\n" << " --export-format <format> export project to a file, rather than making a DCP: specify mov or mp4\n" << " --export-filename <filename> filename to export to with --export-format\n" + << " --hints show hints and stop if any are given\n" << "\n" << "<FILM> is the film directory.\n"; } @@ -270,6 +272,7 @@ main (int argc, char* argv[]) bool check = true; optional<string> export_format; optional<boost::filesystem::path> export_filename; + bool hints = false; int option_index = 0; while (true) { @@ -291,10 +294,11 @@ main (int argc, char* argv[]) { "no-check", no_argument, 0, 'B' }, { "export-format", required_argument, 0, 'C' }, { "export-filename", required_argument, 0, 'D' }, + { "hints", no_argument, 0, 'E' }, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vhfnrt:j:kAs:ldc:BC:D:", long_options, &option_index); + int c = getopt_long (argc, argv, "vhfnrt:j:kAs:ldc:BC:D:E", long_options, &option_index); if (c == -1) { break; @@ -350,6 +354,9 @@ main (int argc, char* argv[]) case 'D': export_filename = optarg; break; + case 'E': + hints = true; + break; } } @@ -442,6 +449,49 @@ main (int argc, char* argv[]) } } + if (!export_format && hints) { + string const prefix = "Checking project for hints"; + bool pulse_phase = false; + vector<string> hints; + bool finished = false; + + Hints hint_finder(film); + hint_finder.Progress.connect([prefix](string progress) { + std::cout << UP_ONE_LINE_AND_ERASE << prefix << ": " << progress << "\n"; + std::cout.flush(); + }); + hint_finder.Pulse.connect([prefix, &pulse_phase]() { + std::cout << UP_ONE_LINE_AND_ERASE << prefix << ": " << (pulse_phase ? "X" : "x") << "\n"; + std::cout.flush(); + pulse_phase = !pulse_phase; + }); + hint_finder.Hint.connect([&hints](string hint) { + hints.push_back(hint); + }); + hint_finder.Finished.connect([&finished]() { + finished = true; + }); + + std::cout << prefix << ":\n"; + std::cout.flush(); + + hint_finder.start(); + while (!finished) { + signal_manager->ui_idle(); + dcpomatic_sleep_milliseconds(200); + } + + std::cout << UP_ONE_LINE_AND_ERASE; + + if (!hints.empty()) { + std::cout << "Hints:\n\n"; + for (auto hint: hints) { + std::cout << word_wrap("* " + hint, 70) << "\n"; + } + exit(EXIT_FAILURE); + } + } + if (progress) { if (export_format) { cout << "\nExporting " << film->name() << "\n"; |
