looqs/cli/commandlist.cpp

37 line
846 B
C++

2019-09-22 16:13:13 +02:00
#include <QCommandLineParser>
#include "commandlist.h"
#include "logger.h"
int CommandList::handle(QStringList arguments)
{
QCommandLineParser parser;
parser.addOptions({
{"pattern", "Only list files from index matching the pattern, e. g. '*.txt'", "pattern"},
2019-09-22 16:13:13 +02:00
});
parser.addHelpOption();
parser.addPositionalArgument("list", "Lists paths in the index", "list [options]");
parser.process(arguments);
QString pattern = parser.value("pattern");
QVector<FileData> results;
2019-09-22 16:13:13 +02:00
int offset = 0;
int limit = 1000;
auto resultscount = dbService->getFiles(results, pattern, offset, limit);
while(resultscount > 0)
2019-09-22 16:13:13 +02:00
{
for(FileData &fileData : results)
{
Logger::info() << fileData.absPath << Qt::endl;
}
offset += limit;
results.clear();
resultscount = dbService->getFiles(results, pattern, offset, limit);
2019-09-22 16:13:13 +02:00
}
return 0;
2019-09-22 16:13:13 +02:00
}