2019-09-22 16:13:13 +02:00
|
|
|
#include <QCommandLineParser>
|
|
|
|
#include "commandlist.h"
|
|
|
|
#include "databasefactory.h"
|
|
|
|
#include "logger.h"
|
|
|
|
|
|
|
|
int CommandList::handle(QStringList arguments)
|
|
|
|
{
|
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.addOptions({
|
2022-06-02 14:35:23 +02:00
|
|
|
{"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);
|
|
|
|
|
2022-06-02 14:35:23 +02:00
|
|
|
QString pattern = parser.value("pattern");
|
|
|
|
|
|
|
|
QVector<FileData> results;
|
2019-09-22 16:13:13 +02:00
|
|
|
|
2022-06-02 14:35:23 +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
|
|
|
{
|
2022-06-02 14:35:23 +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
|
|
|
}
|
2020-05-24 15:37:47 +02:00
|
|
|
return 0;
|
2019-09-22 16:13:13 +02:00
|
|
|
}
|