2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <boost/filesystem.hpp>
26 #include "lib/version.h"
29 #include "lib/content_factory.h"
30 #include "lib/job_manager.h"
31 #include "lib/ui_signaller.h"
39 using boost::shared_ptr;
44 cerr << "Create a film directory (ready for making a DCP) from some content files.\n"
45 << "Syntax: " << n << " [OPTION] <CONTENT> [<CONTENT> ...]\n"
46 << " -v, --version show DCP-o-matic version\n"
47 << " -h, --help show this help\n"
48 << " -n, --name film name\n"
49 << " -o, --output output directory (required)\n";
53 main (int argc, char* argv[])
56 boost::filesystem::path output;
60 static struct option long_options[] = {
61 { "version", no_argument, 0, 'v'},
62 { "help", no_argument, 0, 'h'},
63 { "name", required_argument, 0, 'n'},
64 { "output", required_argument, 0, 'o'},
68 int c = getopt_long (argc, argv, "vhn:o:", long_options, &option_index);
75 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
94 if (output.empty ()) {
95 cerr << "Missing required option -o or --output.\n"
96 << "Use " << argv[0] << " --help for help.\n";
101 ui_signaller = new UISignaller ();
104 shared_ptr<Film> film (new Film (output));
105 if (!name.empty ()) {
106 film->set_name (name);
109 for (int i = optind; i < argc; ++i) {
110 film->examine_and_add_content (content_factory (film, argv[i]));
113 JobManager* jm = JobManager::instance ();
114 while (jm->work_to_do ()) {
115 ui_signaller->ui_idle ();
119 list<shared_ptr<Job> > jobs = jm->get ();
120 for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
121 if ((*i)->finished_in_error ()) {
122 cerr << (*i)->error_summary () << "\n"
123 << (*i)->error_details () << "\n";
129 film->write_metadata ();
130 } catch (exception& e) {
131 cerr << argv[0] << ": " << e.what() << "\n";