cli: CommandSearch: Improve error handling, helptext fixes
这个提交包含在:
父节点
6f11a5e662
当前提交
51ead5e171
@ -8,14 +8,19 @@ int CommandSearch::handle(QStringList arguments)
|
||||
QCommandLineParser parser;
|
||||
parser.addOptions({
|
||||
{{"r", "reverse"},
|
||||
"Print most-recent changed files first. This is short for adding \"sort:(mtime asc)\" to the query."},
|
||||
"Print most-recently changed files last. This is short for adding \"sort:(mtime asc)\" to the query."},
|
||||
});
|
||||
|
||||
parser.addHelpOption();
|
||||
parser.process(arguments);
|
||||
|
||||
QStringList files = parser.positionalArguments();
|
||||
QString queryStrings = files.join(' ');
|
||||
QStringList terms = parser.positionalArguments();
|
||||
if(terms.length() == 0)
|
||||
{
|
||||
Logger::error() << "Please enter search terms" << Qt::endl;
|
||||
return 1;
|
||||
}
|
||||
QString queryStrings = terms.join(' ');
|
||||
LooqsQuery query = LooqsQuery::build(queryStrings, TokenType::FILTER_PATH_CONTAINS, false);
|
||||
bool reverse = parser.isSet("reverse");
|
||||
if(reverse)
|
||||
@ -26,11 +31,19 @@ int CommandSearch::handle(QStringList arguments)
|
||||
query.addSortCondition(sc);
|
||||
}
|
||||
|
||||
auto results = dbService->search(query);
|
||||
|
||||
for(SearchResult &result : results)
|
||||
try
|
||||
{
|
||||
Logger::info() << result.fileData.absPath << Qt::endl;
|
||||
auto results = dbService->search(query);
|
||||
|
||||
for(SearchResult &result : results)
|
||||
{
|
||||
Logger::info() << result.fileData.absPath << Qt::endl;
|
||||
}
|
||||
}
|
||||
catch(LooqsGeneralException &e)
|
||||
{
|
||||
Logger::error() << "Exception:" << e.message << Qt::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户