From e23004cb4001ab73d41cb79883d62aed84b6399f Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 9 Dec 2014 22:41:53 +0100 Subject: add a * to check all --- tests/hawd/modules/check.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/hawd/modules/check.cpp') diff --git a/tests/hawd/modules/check.cpp b/tests/hawd/modules/check.cpp index c83ed39..1359b3d 100644 --- a/tests/hawd/modules/check.cpp +++ b/tests/hawd/modules/check.cpp @@ -21,6 +21,7 @@ #include "../datasetdefinition.h" +#include #include #include @@ -32,6 +33,7 @@ Check::Check() : Module() { Syntax top("check", &Check::check); + setDescription(QObject::tr("Checks a dataset description for validity and prints out any errors it finds")); setSyntax(top); } @@ -41,11 +43,14 @@ bool Check::check(const QStringList &commands, State &state) std::cout << QObject::tr("Please provide the name of a dataset definition file. (Use the 'list' command to see available datasets.)").toStdString() << std::endl; } else { for (const QString &name: commands) { - DatasetDefinition def = state.datasetDefinition(name); - if (def.isValid()) { - std::cout << QObject::tr("%1 is OK").arg(name).toStdString() << std::endl; + if (name == "*") { + QDir project(state.projectPath()); + project.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot | QDir::NoSymLinks); + for (const QString &entry: project.entryList()) { + checkFile(entry, state); + } } else { - std::cout << QObject::tr("%1 has errors: %2").arg(name).arg(def.lastError()).toStdString() << std::endl; + checkFile(name, state); } } } @@ -53,5 +58,15 @@ bool Check::check(const QStringList &commands, State &state) return true; } +void Check::checkFile(const QString &name, State &state) +{ + DatasetDefinition def = state.datasetDefinition(name); + if (def.isValid()) { + std::cout << QObject::tr("%1 is OK").arg(name).toStdString() << std::endl; + } else { + std::cout << QObject::tr("%1 has errors: %2").arg(name).arg(def.lastError()).toStdString() << std::endl; + } +} + } // namespace HAWD -- cgit v1.2.3