validate arguments

This commit is contained in:
yggverse 2024-03-21 23:22:50 +02:00
parent e01ad2ebdb
commit cd88a971e7

View File

@ -10,6 +10,14 @@ $config = json_decode(
) )
); );
// Validate request
if (empty($argv[1]))
{
exit(
_('search query required as the first argument!') . PHP_EOL
);
}
// Init client // Init client
$client = new \Manticoresearch\Client( $client = new \Manticoresearch\Client(
[ [
@ -25,7 +33,7 @@ $index = $client->index(
// Search // Search
foreach($index->search($argv[1]) foreach($index->search($argv[1])
->limit($argv[2] ? $argv[2] : 10) ->limit(isset($argv[2]) ? (int) $argv[2] : 10)
->get() as $result) ->get() as $result)
{ {
var_dump( var_dump(