mirror of
https://github.com/YGGverse/Yo.git
synced 2026-03-31 17:55:35 +00:00
validate arguments
This commit is contained in:
parent
e01ad2ebdb
commit
cd88a971e7
1 changed files with 9 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue