Skip to content

Commit

Permalink
feat(methods): Get method and payload from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
nahime0 committed Nov 11, 2023
1 parent 5610652 commit 78dd41e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ public function handleArguments(array $arguments): array
if (str_starts_with($argument, '--concurrency=')) {
$run->concurrently((int) str_replace('--concurrency=', '', $argument));
}

if (str_starts_with($argument, '--method=')) {
$run->method(str_replace('--method=', '', $argument));
}

if (str_starts_with($argument, '--payload=')) {
try {
$payload = json_decode(str_replace('--payload=', '', $argument),
true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
View::render('components.badge', [
'type' => 'ERROR',
'content' => 'Invalid JSON payload. Please provide a valid JSON payload.' .
'Example: --payload=\'{"name": "Nuno"}\''
]);

exit(0);
}
$run->payload($payload);
}
}

$run->dd();
Expand Down

0 comments on commit 78dd41e

Please sign in to comment.