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({
|
|
|
|
{{"r", "reverse"}, "Print most-recent changed files first"},
|
|
|
|
{{"c", "count"}, "Counts the number of paths listed"},
|
|
|
|
{"pattern", "Only list files from index matching the pattern, e. g. */.git/*", "pattern"},
|
|
|
|
});
|
|
|
|
|
|
|
|
parser.addHelpOption();
|
|
|
|
parser.addPositionalArgument("list", "Lists paths in the index", "list [options]");
|
|
|
|
|
|
|
|
parser.process(arguments);
|
|
|
|
bool reverse = parser.isSet("reverse");
|
|
|
|
if(reverse)
|
|
|
|
{
|
2021-06-12 14:59:58 +02:00
|
|
|
throw LooqsGeneralException("Reverse option to be implemented");
|
2019-09-22 16:13:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList files = parser.positionalArguments();
|
|
|
|
QString queryStrings = files.join(' ');
|
2021-12-30 12:17:12 +01:00
|
|
|
auto results = dbService->search(LooqsQuery::build(queryStrings, TokenType::FILTER_PATH_CONTAINS, false));
|
2019-09-22 16:13:13 +02:00
|
|
|
|
|
|
|
for(SearchResult &result : results)
|
|
|
|
{
|
2021-06-12 22:55:56 +02:00
|
|
|
Logger::info() << result.fileData.absPath << Qt::endl;
|
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
|
|
|
}
|