cli: CommandSearch: Improve error handling, helptext fixes
このコミットが含まれているのは:
コミット
51ead5e171
@ -8,14 +8,19 @@ int CommandSearch::handle(QStringList arguments)
|
|||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addOptions({
|
parser.addOptions({
|
||||||
{{"r", "reverse"},
|
{{"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.addHelpOption();
|
||||||
parser.process(arguments);
|
parser.process(arguments);
|
||||||
|
|
||||||
QStringList files = parser.positionalArguments();
|
QStringList terms = parser.positionalArguments();
|
||||||
QString queryStrings = files.join(' ');
|
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);
|
LooqsQuery query = LooqsQuery::build(queryStrings, TokenType::FILTER_PATH_CONTAINS, false);
|
||||||
bool reverse = parser.isSet("reverse");
|
bool reverse = parser.isSet("reverse");
|
||||||
if(reverse)
|
if(reverse)
|
||||||
@ -26,11 +31,19 @@ int CommandSearch::handle(QStringList arguments)
|
|||||||
query.addSortCondition(sc);
|
query.addSortCondition(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto results = dbService->search(query);
|
try
|
||||||
|
|
||||||
for(SearchResult &result : results)
|
|
||||||
{
|
{
|
||||||
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;
|
return 0;
|
||||||
|
読み込み中…
新しいイシューから参照
ユーザーをブロックする