Browse Source

validate arguments

main
yggverse 8 months ago
parent
commit
cd88a971e7
  1. 10
      src/cli/document/search.php

10
src/cli/document/search.php

@ -10,6 +10,14 @@ $config = json_decode( @@ -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
$client = new \Manticoresearch\Client(
[
@ -25,7 +33,7 @@ $index = $client->index( @@ -25,7 +33,7 @@ $index = $client->index(
// Search
foreach($index->search($argv[1])
->limit($argv[2] ? $argv[2] : 10)
->limit(isset($argv[2]) ? (int) $argv[2] : 10)
->get() as $result)
{
var_dump(

Loading…
Cancel
Save