forked from Flowee/registry
Make the basic program structure work.
This commit is contained in:
+2
-1
@@ -22,10 +22,11 @@ add_executable(processor
|
|||||||
main.cpp
|
main.cpp
|
||||||
Processor.h Processor.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
|
target_link_libraries(processor
|
||||||
flowee_utils
|
flowee_utils
|
||||||
Qt6::Core
|
Qt6::Core
|
||||||
|
Boost::filesystem
|
||||||
)
|
)
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/processor DESTINATION ${CMAKE_BINARY_DIR}/bin)
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/processor DESTINATION ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
|||||||
+12
-1
@@ -1,5 +1,8 @@
|
|||||||
#include "Processor.h"
|
#include "Processor.h"
|
||||||
|
|
||||||
|
#include <utils/Logger.h>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
Processor::Processor(const QString &inDir, const QString &outDir)
|
Processor::Processor(const QString &inDir, const QString &outDir)
|
||||||
: m_inDir(inDir),
|
: m_inDir(inDir),
|
||||||
m_outDir(outDir)
|
m_outDir(outDir)
|
||||||
@@ -8,5 +11,13 @@ Processor::Processor(const QString &inDir, const QString &outDir)
|
|||||||
|
|
||||||
int Processor::run()
|
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
@@ -1,19 +1,48 @@
|
|||||||
#include "Processor.h"
|
#include "Processor.h"
|
||||||
|
|
||||||
|
#include <utils/Logger.h>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
int main(int x, char **y) {
|
int main(int x, char **y) {
|
||||||
QCoreApplication app(x, y);
|
QCoreApplication app(x, y);
|
||||||
|
app.setApplicationName("processor");
|
||||||
|
app.setApplicationVersion("0.1");
|
||||||
|
app.setOrganizationName("flowee");
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
|
||||||
parser.setApplicationDescription("Processor for the cashing BCM-Registry");
|
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();
|
auto args = parser.positionalArguments();
|
||||||
if (args.size() != 2) {
|
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));
|
Processor processor(args.at(0), args.at(1));
|
||||||
return processor.run();
|
return processor.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user