mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 17:27:22 +01:00
feat: adds --version option
This commit is contained in:
10
src/Pest.php
Normal file
10
src/Pest.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '0.2.2';
|
||||
}
|
||||
39
src/Plugins/Version.php
Normal file
39
src/Plugins/Version.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins;
|
||||
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use function Pest\version;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Version implements HandlesArguments
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the plugin.
|
||||
*/
|
||||
public function __construct(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
public function handleArguments(array $arguments): array
|
||||
{
|
||||
if (in_array('--version', $arguments, true)) {
|
||||
$this->output->writeln(
|
||||
sprintf('Pest %s', version()),
|
||||
);
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user