search from CLI for integration with other unix tools

This commit is contained in:
Shish 2019-10-04 20:48:59 +01:00
parent 4564fd4092
commit 577d5c572a

View File

@ -203,6 +203,24 @@ class Index extends Extension
} }
} }
public function onCommand(CommandEvent $event)
{
if ($event->cmd == "help") {
print "\tsearch <query>\n";
print "\t\tsearch the database and print results\n\n";
}
if ($event->cmd == "search") {
if (count($event->args) < 1) {
return;
}
$query = count($event) > 0 ? Tag::explode($event->args[0]) : [];
$items = Image::find_images(0, null, $query);
foreach ($items as $item) {
print("{$item->hash}\n");
}
}
}
public function onSearchTermParse(SearchTermParseEvent $event) public function onSearchTermParse(SearchTermParseEvent $event)
{ {