From cd88a971e7b9edf701e8a55e0673bfde8ed17f5b Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 21 Mar 2024 23:22:50 +0200 Subject: [PATCH] validate arguments --- src/cli/document/search.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cli/document/search.php b/src/cli/document/search.php index 0515b63..be02393 100644 --- a/src/cli/document/search.php +++ b/src/cli/document/search.php @@ -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( // 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(