Albert S
407ee1210c
Search for content and paths. Merge lone words for content search. This behaviour is much more natural than typing "c:()".
36 baris
1004 B
C++
36 baris
1004 B
C++
#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)
|
|
{
|
|
throw LooqsGeneralException("Reverse option to be implemented");
|
|
}
|
|
|
|
QStringList files = parser.positionalArguments();
|
|
QString queryStrings = files.join(' ');
|
|
auto results = dbService->search(LooqsQuery::build(queryStrings, TokenType::FILTER_PATH_CONTAINS, false));
|
|
|
|
for(SearchResult &result : results)
|
|
{
|
|
Logger::info() << result.fileData.absPath << Qt::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|