Make the basic program structure work.

This commit is contained in:
2025-04-08 20:10:02 +02:00
parent 1c4fb77acd
commit 42c25aa795
3 changed files with 46 additions and 5 deletions
+2 -1
View File
@@ -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)
+12 -1
View File
@@ -1,5 +1,8 @@
#include "Processor.h"
#include <utils/Logger.h>
#include <QDirIterator>
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;
}
+32 -3
View File
@@ -1,19 +1,48 @@
#include "Processor.h"
#include <utils/Logger.h>
#include <QCommandLineParser>
#include <QCoreApplication>
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();
}