Mercurial > hg > sonic-annotator
diff runner/main.cpp @ 255:0774f36cb151
Add --transform-minversion flag
author | Chris Cannam |
---|---|
date | Thu, 15 Sep 2016 11:31:03 +0100 |
parents | 4307b34f86c0 |
children | 68dc2d99a5b1 |
line wrap: on
line diff
--- a/runner/main.cpp Tue Aug 16 16:49:22 2016 +0100 +++ b/runner/main.cpp Thu Sep 15 11:31:03 2016 +0100 @@ -362,6 +362,11 @@ + myname + " is at least <V>, failure otherwise." " For scripts that depend on certain option support.") << endl << endl; + cerr << " --transform-minversion <I> <V>\n" + << " " + << wrapCol("Exit with successful return code if the plugin providing " + " transform id <I> is at least <V>, failure otherwise.") + << endl << endl; cerr << " -h, --help Show help." << endl; cerr << " -h, --help <W> Show help for writer type W." << endl; cerr << " " << writerText << endl; @@ -443,6 +448,26 @@ cout << rdf; } +static int +checkTransformMinVersion(QString myname, QString id, int version) +{ + Transform transform = + TransformFactory::getInstance()->getDefaultTransformFor(id); + QString pvs = transform.getPluginVersion(); + bool ok = false; + int pv = pvs.toInt(&ok); + if (!ok) { + cerr << myname << ": transform version \"" << pvs << "\" is not an integer" + << endl; + return 1; + } + if (pv >= version) { + return 0; + } else { + return 1; + } +} + void findSourcesRecursive(QString dirname, QStringList &addTo, int &found) { @@ -581,6 +606,7 @@ bool summaryOnly = false; QString skeletonFor = ""; QString minVersion = ""; + pair<QString, QString> transformMinVersion; QString myname = args[0]; myname = QFileInfo(myname).baseName(); QStringList otherArgs; @@ -748,6 +774,18 @@ } minVersion = args[++i]; continue; + } else if (arg == "--transform-minversion") { + if (last || (i+2) == args.size() || + args[i+1].startsWith("-") || + args[i+2].startsWith("-")) { + cerr << myname << ": usage: " + << myname << " " << arg << " <version>" << endl; + cerr << helpStr << endl; + exit(2); + } + transformMinVersion = { args[i+1], args[i+2] }; + i += 2; + continue; } else if (arg == "-s" || arg == "--skeleton") { if (last || args[i+1].startsWith("-")) { cerr << myname << ": usage: " @@ -828,6 +866,21 @@ } exit(checkMinVersion(myname, minVersion)); } + if (transformMinVersion.first != "") { + if (!requestedWriterTags.empty()) { + cerr << helpStr << endl; + exit(2); + } + bool ok = false; + int version = transformMinVersion.second.toInt(&ok); + if (!ok) { + cerr << myname << ": plugin version \"" << transformMinVersion.second + << "\" must be an integer" << endl; + cerr << helpStr << endl; + exit(2); + } + exit(checkTransformMinVersion(myname, transformMinVersion.first, version)); + } if (requestedTransformFiles.empty() && requestedTransformListFiles.empty() &&