Debug.
[libdcp.git] / tools / dcpverify.cc
index d246dc659821879a4c50da76df2bd2ef54b226cd..c484516e54c5ebe8f42c63631eaf92ef9d33a2b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -32,6 +32,8 @@
 */
 
 #include "verify.h"
+#include "compose.hpp"
+#include "common.h"
 #include <boost/bind.hpp>
 #include <boost/optional.hpp>
 #include <boost/filesystem.hpp>
@@ -52,13 +54,19 @@ static void
 help (string n)
 {
        cerr << "Syntax: " << n << " [OPTION] <DCP>\n"
-            << "  -V, --version   show libdcp version\n"
-            << "  -h, --help      show this help\n";
+            << "  -V, --version           show libdcp version\n"
+            << "  -h, --help              show this help\n"
+            << "  --ignore-missing-assets don't give errors about missing assets\n"
+            << "  -q, --quiet             don't report progress\n";
 }
 
 void
-stage (string s, optional<boost::filesystem::path> path)
+stage (bool quiet, string s, optional<boost::filesystem::path> path)
 {
+       if (quiet) {
+               return;
+       }
+
        if (path) {
                cout << s << ": " << path->string() << "\n";
        } else {
@@ -75,15 +83,22 @@ progress ()
 int
 main (int argc, char* argv[])
 {
+       dcp::init ();
+
+       bool ignore_missing_assets = false;
+       bool quiet = false;
+
        int option_index = 0;
        while (true) {
                static struct option long_options[] = {
-                       { "version", no_argument, 0, 'V'},
-                       { "help", no_argument, 0, 'h'},
+                       { "version", no_argument, 0, 'V' },
+                       { "help", no_argument, 0, 'h' },
+                       { "ignore-missing-assets", no_argument, 0, 'A' },
+                       { "quiet", no_argument, 0, 'q' },
                        { 0, 0, 0, 0 }
                };
 
-               int c = getopt_long (argc, argv, "Vh", long_options, &option_index);
+               int c = getopt_long (argc, argv, "VhAq", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -96,6 +111,12 @@ main (int argc, char* argv[])
                case 'h':
                        help (argv[0]);
                        exit (EXIT_SUCCESS);
+               case 'A':
+                       ignore_missing_assets = true;
+                       break;
+               case 'q':
+                       quiet = true;
+                       break;
                }
        }
 
@@ -111,25 +132,23 @@ main (int argc, char* argv[])
 
        vector<boost::filesystem::path> directories;
        directories.push_back (argv[optind]);
-       list<dcp::VerificationNote> notes = dcp::verify (directories, bind(&stage, _1, _2), bind(&progress));
+       list<dcp::VerificationNote> notes = dcp::verify (directories, bind(&stage, quiet, _1, _2), bind(&progress), "xsd");
+       dcp::filter_notes (notes, ignore_missing_assets);
 
        bool failed = false;
        BOOST_FOREACH (dcp::VerificationNote i, notes) {
                switch (i.type()) {
                case dcp::VerificationNote::VERIFY_ERROR:
-                       cout << "Error: " << i.note() << "\n";
+                       cout << "Error: " << note_to_string(i) << "\n";
                        failed = true;
                        break;
                case dcp::VerificationNote::VERIFY_WARNING:
-                       cout << "Warning: " << i.note() << "\n";
-                       break;
-               case dcp::VerificationNote::VERIFY_NOTE:
-                       cout << "Note: " << i.note() << "\n";
+                       cout << "Warning: " << note_to_string(i) << "\n";
                        break;
                }
        }
 
-       if (!failed) {
+       if (!failed && !quiet) {
                cout << "DCP verified OK.\n";
        }