Mercurial > hg > sonic-annotator
changeset 255:0774f36cb151
Add --transform-minversion flag
author | Chris Cannam |
---|---|
date | Thu, 15 Sep 2016 11:31:03 +0100 |
parents | e257f776a589 |
children | ffa60ff17a86 |
files | runner/main.cpp tests/test-helpfulflags/test-helpfulflags.sh version.h |
diffstat | 3 files changed, 60 insertions(+), 1 deletions(-) [+] |
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() &&
--- a/tests/test-helpfulflags/test-helpfulflags.sh Tue Aug 16 16:49:22 2016 +0100 +++ b/tests/test-helpfulflags/test-helpfulflags.sh Thu Sep 15 11:31:03 2016 +0100 @@ -41,4 +41,10 @@ $r --minversion 63.9 2>/dev/null && \ fail "Returned success code when run with --minversion 63.9" +$r --transform-minversion $percplug 1 || \ + fail "Returned failure code when run with --transform-minversion $percplug 1" + +$r --transform-minversion $percplug 50 2>/dev/null && \ + fail "Returned success code when run with --transform-minversion $percplug 50" + exit 0