From 3e1f008d416a5d0493b799599e1e6ee29785d754 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 9 Sep 2022 01:48:52 +0200 Subject: Make -S parameter to dcpomatic2_kdm_cli also filter screens (#2324). --- src/lib/kdm_cli.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/lib/kdm_cli.cc') diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index 56977b521..79e65f9de 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -423,7 +423,7 @@ try optional cinema_name; shared_ptr cinema; optional certificate; - string screen; + optional screen; list> screens; optional dkdm; optional valid_from; @@ -440,6 +440,9 @@ try program_name = argv[0]; + /* Reset getopt() so we can call this method several times in one test process */ + optind = 1; + int option_index = 0; while (true) { static struct option long_options[] = { @@ -535,6 +538,9 @@ try cinema = make_shared(optarg, list(), "", 0, 0); break; case 'S': + /* Similarly, this could be the name of a new (temporary) screen or the name of a screen + * to search for. + */ screen = optarg; break; case 'C': @@ -558,7 +564,7 @@ try if (certificate) { /* Make a new screen and add it to the current cinema */ dcp::CertificateChain chain(dcp::file_to_string(*certificate)); - auto screen_to_add = std::make_shared(screen, "", chain.leaf(), boost::none, vector()); + auto screen_to_add = std::make_shared(screen.get_value_or(""), "", chain.leaf(), boost::none, vector()); if (cinema) { cinema->add_screen(screen_to_add); } @@ -596,6 +602,9 @@ try } screens = find_cinema (*cinema_name)->screens (); + if (screen) { + screens.erase(std::remove_if(screens.begin(), screens.end(), [&screen](shared_ptr s) { return s->name != *screen; }), screens.end()); + } } if (duration_string) { -- cgit v1.2.3