Create AbstractSpinnerCommand and BuildCommand
This commit is contained in:
parent
3e6c4b9bab
commit
0afce1ab9e
5 changed files with 71 additions and 3 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Loom | Spinner
|
||||
|
||||
An environment management application for PHP development.
|
15
bin/spinner
15
bin/spinner
|
@ -1,4 +1,17 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
use Loom\Spinner\Command\SpinCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
$application = new Application('Loom Spinner');
|
||||
|
||||
$application->add(new SpinCommand());
|
||||
|
||||
try {
|
||||
$application->run();
|
||||
} catch (\Exception $exception) {
|
||||
die();
|
||||
}
|
|
@ -2,7 +2,18 @@
|
|||
"name": "loomlabs/spinner",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spinner\\": "src/"
|
||||
"Loom\\Spinner\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Loom\\Spinner\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"symfony/console": "^7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^12.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
20
src/Command/AbstractSpinnerCommand.php
Normal file
20
src/Command/AbstractSpinnerCommand.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Loom\Spinner\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class AbstractSpinnerCommand extends Command
|
||||
{
|
||||
protected SymfonyStyle $style;
|
||||
|
||||
protected function setStyle(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$this->style = new SymfonyStyle($input, $output);
|
||||
}
|
||||
}
|
21
src/Command/SpinCommand.php
Normal file
21
src/Command/SpinCommand.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Loom\Spinner\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[AsCommand(name: 'spin', description: 'Spin up a new development environment')]
|
||||
class SpinCommand extends AbstractSpinnerCommand
|
||||
{
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->setStyle($input, $output);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue