mirror of
https://github.com/YGGverse/Yo.git
synced 2025-02-05 11:24:20 +00:00
validate arguments
This commit is contained in:
parent
e01ad2ebdb
commit
cd88a971e7
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user