diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e096da..9a1a95b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,10 +22,11 @@ add_executable(processor main.cpp Processor.h Processor.cpp ) -target_compile_definitions(processor PRIVATE LOG_DEFAULT_SECTION=40000) +target_compile_definitions(processor PRIVATE LOG_DEFAULT_SECTION=100) target_link_libraries(processor flowee_utils Qt6::Core + Boost::filesystem ) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/processor DESTINATION ${CMAKE_BINARY_DIR}/bin) diff --git a/src/Processor.cpp b/src/Processor.cpp index 7f03fc3..b996d40 100644 --- a/src/Processor.cpp +++ b/src/Processor.cpp @@ -1,5 +1,8 @@ #include "Processor.h" +#include +#include + Processor::Processor(const QString &inDir, const QString &outDir) : m_inDir(inDir), m_outDir(outDir) @@ -8,5 +11,13 @@ Processor::Processor(const QString &inDir, const QString &outDir) int Processor::run() { - + if (!QDir::current().mkpath(m_outDir)) { + logCritical() << "Failed to create target dir"; + return 1; + } + QDirIterator iter(m_inDir, QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDirIterator::Subdirectories); + while (iter.hasNext()) { + logFatal() << "File:" << iter.next(); + } + return 0; } diff --git a/src/main.cpp b/src/main.cpp index f2b290e..6a50cc3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,48 @@ #include "Processor.h" +#include #include #include int main(int x, char **y) { QCoreApplication app(x, y); + app.setApplicationName("processor"); + app.setApplicationVersion("0.1"); + app.setOrganizationName("flowee"); QCommandLineParser parser; parser.addHelpOption(); - parser.addVersionOption(); parser.setApplicationDescription("Processor for the cashing BCM-Registry"); - parser.parse(app.arguments()); + parser.addPositionalArgument("input-dir", "The directory with all the gathered source data", "IN_DIR"); + parser.addPositionalArgument("output-dir", "The directory to generate the output in", "OUT_DIR"); + QCommandLineOption debug(QStringList() << "debug", "Use debug level logging"); + parser.addOption(debug); + QCommandLineOption verbose(QStringList() << "verbose" << "v", "Be more verbose"); + parser.addOption(verbose); + QCommandLineOption quiet(QStringList() << "quiet" << "q", "Be quiet, only errors are shown"); + parser.addOption(quiet); + + parser.process(app.arguments()); auto args = parser.positionalArguments(); if (args.size() != 2) { - return 1; + parser.showHelp(1); // exits + assert(false); } + + auto *logger = Log::Manager::instance(); + logger->clearChannels(); + Log::Verbosity v = Log::WarningLevel; +#ifndef BCH_NO_DEBUG_OUTPUT + if (parser.isSet(debug)) + v = Log::DebugLevel; + else +#endif + if (parser.isSet(verbose)) + v = Log::InfoLevel; + else if (parser.isSet(quiet)) + v = Log::FatalLevel; + logger->clearLogLevels(v); + logger->addConsoleChannel(); + Processor processor(args.at(0), args.at(1)); return processor.run(); }